Skip to content

Fix edge-case Protocol bug on Python 3.7 - #242

Merged
JelleZijlstra merged 2 commits into
python:mainfrom
AlexWaygood:proto-subclass-bug
Jun 16, 2023
Merged

JelleZijlstra merged 2 commits into
python:mainfrom
AlexWaygood:proto-subclass-bug

Conversation

@AlexWaygood

Copy link
Copy Markdown
Member

This line is buggy. As a result of the bug, several of the assertions added in python/cpython#105835 don't pass on Python 3.7:

and issubclass(other, (typing.Generic, _ProtocolMeta))

It should be

issubclass(other, typing.Generic) or isinstance(other, _ProtocolMeta)

But we can also rewrite the condition more elegantly using the new is_protocol function, so that's what I've done in this PR.

Comment thread src/typing_extensions.py Resolved
@JelleZijlstra
JelleZijlstra merged commit af89916 into python:main Jun 16, 2023
@AlexWaygood
AlexWaygood deleted the proto-subclass-bug branch June 16, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants