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

Method __new__

tools/python-3.11.9-amd64/Lib/datetime.py:1336–1373  ·  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

1334 __slots__ = '_hour', '_minute', '_second', '_microsecond', '_tzinfo', '_hashcode', '_fold'
1335
1336 def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0):
1337 """Constructor.
1338
1339 Arguments:
1340
1341 hour, minute (required)
1342 second, microsecond (default to zero)
1343 tzinfo (default to None)
1344 fold (keyword only, default to zero)
1345 """
1346 if (isinstance(hour, (bytes, str)) and len(hour) == 6 and
1347 ord(hour[0:1])&0x7F < 24):
1348 # Pickle support
1349 if isinstance(hour, str):
1350 try:
1351 hour = hour.encode('latin1')
1352 except UnicodeEncodeError:
1353 # More informative error message.
1354 raise ValueError(
1355 "Failed to encode latin1 string when unpickling "
1356 "a time object. "
1357 "pickle.load(data, encoding='latin1') is assumed.")
1358 self = object.__new__(cls)
1359 self.__setstate(hour, minute or None)
1360 self._hashcode = -1
1361 return self
1362 hour, minute, second, microsecond, fold = _check_time_fields(
1363 hour, minute, second, microsecond, fold)
1364 _check_tzinfo_arg(tzinfo)
1365 self = object.__new__(cls)
1366 self._hour = hour
1367 self._minute = minute
1368 self._second = second
1369 self._microsecond = microsecond
1370 self._tzinfo = tzinfo
1371 self._hashcode = -1
1372 self._fold = fold
1373 return self
1374
1375 # Read-only field accessors
1376 @property

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected