MCPcopy Index your code
hub / github.com/python/cpython / __new__

Method __new__

Lib/_pydatetime.py:2451–2464  ·  view source on GitHub ↗
(cls, offset, name=_Omitted)

Source from the content-addressed store, hash-verified

2449 # Sentinel value to disallow None
2450 _Omitted = object()
2451 def __new__(cls, offset, name=_Omitted):
2452 if not isinstance(offset, timedelta):
2453 raise TypeError("offset must be a timedelta")
2454 if name is cls._Omitted:
2455 if not offset:
2456 return cls.utc
2457 name = None
2458 elif not isinstance(name, str):
2459 raise TypeError("name must be a string")
2460 if not cls._minoffset <= offset <= cls._maxoffset:
2461 raise ValueError("offset must be a timedelta "
2462 "strictly between -timedelta(hours=24) and "
2463 f"timedelta(hours=24), not {offset!r}")
2464 return cls._create(offset, name)
2465
2466 def __init_subclass__(cls):
2467 raise TypeError("type 'datetime.timezone' is not an acceptable base type")

Callers

nothing calls this directly

Calls 1

_createMethod · 0.45

Tested by

no test coverage detected