8000 gh-104555: Runtime-checkable protocols: Don't let previous calls to `isinstance()` influence whether `issubclass()` raises an exception by AlexWaygood · Pull Request #104559 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104555: Runtime-checkable protocols: Don't let previous calls to isinstance() influence whether issubclass() raises an exception #104559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 17, 2023
Merged
Prev Previous commit
Next Next commit
who needs codespell when we have carl
Co-authored-by: Carl Meyer <carl@oddbird.net>
  • Loading branch information
AlexWaygood and carljm authored May 16, 2023
commit 04ed9747351f16b86aea6177661d56103cf4aa71
4 changes: 2 additions & 2 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,7 @@ def __init__(self) -> None:

# gh-104555: ABCMeta might cache the result of this isinstance check
# if we called super().__instancecheck__ in the wrong place
# in _ProtocolMeta.__instancheck__...
# in _ProtocolMeta.__instancecheck__...
self.assertIsInstance(Eggs(), Spam)

# ...and if it did, then TypeError wouldn't be raised here!
Expand All @@ -2683,7 +2683,7 @@ def __init__(self, x: T) -> None:

# gh-104555: ABCMeta might cache the result of this isinstance check
# if we called super().__instancecheck__ in the wrong place
# in _ProtocolMeta.__instancheck__...
# in _ProtocolMeta.__instancecheck__...
self.assertIsInstance(Eggs(42), Spam)

# ...and if it did, then TypeError wouldn't be raised here!
Expand Down
0