MCPcopy Index your code
hub / github.com/RustPython/RustPython / __new__

Method __new__

Lib/_pydatetime.py:1754–1787  ·  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

1752 __slots__ = time.__slots__
1753
1754 def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
1755 microsecond=0, tzinfo=None, *, fold=0):
1756 if (isinstance(year, (bytes, str)) and len(year) == 10 and
1757 1 <= ord(year[2:3])&0x7F <= 12):
1758 # Pickle support
1759 if isinstance(year, str):
1760 try:
1761 year = bytes(year, 'latin1')
1762 except UnicodeEncodeError:
1763 # More informative error message.
1764 raise ValueError(
1765 "Failed to encode latin1 string when unpickling "
1766 "a datetime object. "
1767 "pickle.load(data, encoding='latin1') is assumed.")
1768 self = object.__new__(cls)
1769 self.__setstate(year, month)
1770 self._hashcode = -1
1771 return self
1772 year, month, day = _check_date_fields(year, month, day)
1773 hour, minute, second, microsecond, fold = _check_time_fields(
1774 hour, minute, second, microsecond, fold)
1775 _check_tzinfo_arg(tzinfo)
1776 self = object.__new__(cls)
1777 self._year = year
1778 self._month = month
1779 self._day = day
1780 self._hour = hour
1781 self._minute = minute
1782 self._second = second
1783 self._microsecond = microsecond
1784 self._tzinfo = tzinfo
1785 self._hashcode = -1
1786 self._fold = fold
1787 return self
1788
1789 # Read-only field accessors
1790 @property

Callers

nothing calls this directly

Calls 8

__setstateMethod · 0.95
isinstanceFunction · 0.85
lenFunction · 0.85
ordFunction · 0.85
_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