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

Method __new__

Lib/_pydatetime.py:1410–1447  ·  view source on GitHub ↗

Constructor. Arguments: hour, minute (required) second, microsecond (default to zero) tzinfo (default to None) fold (keyword only, default to zero)

(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)

Source from the content-addressed store, hash-verified

1408 __slots__ = '_hour', '_minute', '_second', '_microsecond', '_tzinfo', '_hashcode', '_fold'
1409
1410 def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0):
1411 """Constructor.
1412
1413 Arguments:
1414
1415 hour, minute (required)
1416 second, microsecond (default to zero)
1417 tzinfo (default to None)
1418 fold (keyword only, default to zero)
1419 """
1420 if (isinstance(hour, (bytes, str)) and len(hour) == 6 and
1421 ord(hour[0:1])&0x7F < 24):
1422 # Pickle support
1423 if isinstance(hour, str):
1424 try:
1425 hour = hour.encode('latin1')
1426 except UnicodeEncodeError:
1427 # More informative error message.
1428 raise ValueError(
1429 "Failed to encode latin1 string when unpickling "
1430 "a time object. "
1431 "pickle.load(data, encoding='latin1') is assumed.")
1432 self = object.__new__(cls)
1433 self.__setstate(hour, minute or None)
1434 self._hashcode = -1
1435 return self
1436 hour, minute, second, microsecond, fold = _check_time_fields(
1437 hour, minute, second, microsecond, fold)
1438 _check_tzinfo_arg(tzinfo)
1439 self = object.__new__(cls)
1440 self._hour = hour
1441 self._minute = minute
1442 self._second = second
1443 self._microsecond = microsecond
1444 self._tzinfo = tzinfo
1445 self._hashcode = -1
1446 self._fold = fold
1447 return self
1448
1449 @classmethod
1450 def strptime(cls, date_string, format):

Callers

nothing calls this directly

Calls 8

__setstateMethod · 0.95
isinstanceFunction · 0.85
lenFunction · 0.85
ordFunction · 0.85
_check_time_fieldsFunction · 0.85
_check_tzinfo_argFunction · 0.85
encodeMethod · 0.45
__new__Method · 0.45

Tested by

no test coverage detected