MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __new__

Method __new__

tools/python-3.11.9-amd64/Lib/datetime.py:1673–1706  ·  view source on GitHub ↗
(cls, year, month=None, day=None, hour=0, minute=0, second=0,
                microsecond=0, tzinfo=None, *, fold=0)

Source from the content-addressed store, hash-verified

1671 __slots__ = date.__slots__ + time.__slots__
1672
1673 def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
1674 microsecond=0, tzinfo=None, *, fold=0):
1675 if (isinstance(year, (bytes, str)) and len(year) == 10 and
1676 1 <= ord(year[2:3])&0x7F <= 12):
1677 # Pickle support
1678 if isinstance(year, str):
1679 try:
1680 year = bytes(year, 'latin1')
1681 except UnicodeEncodeError:
1682 # More informative error message.
1683 raise ValueError(
1684 "Failed to encode latin1 string when unpickling "
1685 "a datetime object. "
1686 "pickle.load(data, encoding='latin1') is assumed.")
1687 self = object.__new__(cls)
1688 self.__setstate(year, month)
1689 self._hashcode = -1
1690 return self
1691 year, month, day = _check_date_fields(year, month, day)
1692 hour, minute, second, microsecond, fold = _check_time_fields(
1693 hour, minute, second, microsecond, fold)
1694 _check_tzinfo_arg(tzinfo)
1695 self = object.__new__(cls)
1696 self._year = year
1697 self._month = month
1698 self._day = day
1699 self._hour = hour
1700 self._minute = minute
1701 self._second = second
1702 self._microsecond = microsecond
1703 self._tzinfo = tzinfo
1704 self._hashcode = -1
1705 self._fold = fold
1706 return self
1707
1708 # Read-only field accessors
1709 @property

Callers

nothing calls this directly

Calls 5

__setstateMethod · 0.95
_check_date_fieldsFunction · 0.85
_check_time_fieldsFunction · 0.85
_check_tzinfo_argFunction · 0.85
__new__Method · 0.45

Tested by

no test coverage detected