You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Assigning attributes to typing.NoDefault raises TypeError, but should raise AttributeError #118895
Most sentinels in Python raise AttributeError if you try to assign attributes to them, but typing.NoDefault raises TypeError instead. I think this should be AttributeError, for consistency with other similar objects:
(main) % ./python.exe ~/dev/cpython
Python 3.14.0a0 (heads/main:66f8bb76a1, May 8 2024, 17:00:15) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> None.foo ='bar'
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
None.foo = 'bar'
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'foo' and no __dict__ for setting new attributes
>>> NotImplemented.foo ='bar'
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
NotImplemented.foo = 'bar'
^^^^^^^^^^^^^^^^^^
AttributeError: 'NotImplementedType' object has no attribute 'foo' and no __dict__ for setting new attributes
>>> from typing import NoDefault
>>> NoDefault.foo ='bar'
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
NoDefault.foo = 'bar'
^^^^^^^^^^^^^
TypeError: 'NoDefaultType' object has no attributes (assign to .foo)
Activity
pythongh-118895: Call PyType_Ready() on typing.NoDefault
gh-118895: Call PyType_Ready() on typing.NoDefault (#118897)
pythongh-118895: Call PyType_Ready() on typing.NoDefault (pythonGH-11…
[3.13] gh-118895: Call PyType_Ready() on typing.NoDefault (GH-118897) (…
pythongh-118895: Call PyType_Ready() on typing.NoDefault (python#118897)