Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Assigning attributes totyping.NoDefault raisesTypeError, but should raiseAttributeError #118895

Closed
Labels
3.13bugs and security fixes3.14bugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or error
@AlexWaygood

Description

@AlexWaygood

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp