-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-102433: Use
inspect.getattr_static
in `typing._ProtocolMeta.__in…
…stancecheck__` (#103034)
- Loading branch information
1 parent
d828b35
commit 6d59c9e
Showing
5 changed files
with
142 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
Misc/NEWS.d/next/Library/2023-03-25-16-57-18.gh-issue-102433.L-7x2Q.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:func:`isinstance` checks against :func:`runtime-checkable protocols | ||
<typing.runtime_checkable>` now use :func:`inspect.getattr_static` rather | ||
than :func:`hasattr` to lookup whether attributes exist. This means that | ||
descriptors and :meth:`~object.__getattr__` methods are no longer | ||
unexpectedly evaluated during ``isinstance()`` checks against | ||
runtime-checkable protocols. However, it may also mean that some objects | ||
which used to be considered instances of a runtime-checkable protocol may no | ||
longer be considered instances of that protocol on Python 3.12+, and vice | ||
versa. Most users are unlikely to be affected by this change. Patch by Alex | ||
Waygood. |