Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
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)CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error