Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
Most sentinels in Python raiseAttributeError if you try to assign attributes to them, buttyping.NoDefault raisesTypeError instead. I think this should beAttributeError, for consistency with other similar objects:
(main) % ./python.exe ~/dev/cpythonPython 3.14.0a0 (heads/main:66f8bb76a1, May 8 2024, 17:00:15) [Clang 15.0.0 (clang-1500.3.9.4)] on darwinType "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 typingimport 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)
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS