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

Cannot callissubclass() againsttyping.Protocol on Python 3.12 #105237

Closed
Assignees
AlexWaygood
Labels
3.12only security fixes3.13bugs and security fixestopic-typingtype-bugAn unexpected behavior, bug, or error
@AlexWaygood

Description

@AlexWaygood

Bug report

On Python 3.11, you can do this:

>>>import typing>>>issubclass(object, typing.Protocol)False

But on Python 3.12 (following the backport ofc05c31d), this raises:

>>>import typing>>>issubclass(object, typing.Protocol)Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "C:\Users\alexw\coding\cpython\Lib\typing.py", line 1797, in __subclasscheck__    raise TypeError(TypeError: Instance and class checks can only be used with @runtime_checkable protocols

The new behaviour doesn't make sense. ThatTypeError should only be triggered if a user is callingissubclass() against asubclass oftyping.Protocol.typing.Protocol itself should be exempted.

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs 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