diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-04-02 13:22:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-02 13:22:19 (GMT) |
commit | 6d59c9e32ebb6d8468c7eb26e7cf3efd458c7a73 (patch) | |
tree | 908d594aba573e0e8d2e2b7edb87a8b4a93101df /Doc/whatsnew | |
parent | d828b35785eeb590b8ca92684038f33177989e46 (diff) | |
download | cpython-6d59c9e32ebb6d8468c7eb26e7cf3efd458c7a73.zip cpython-6d59c9e32ebb6d8468c7eb26e7cf3efd458c7a73.tar.gz cpython-6d59c9e32ebb6d8468c7eb26e7cf3efd458c7a73.tar.bz2 |
gh-102433: Use `inspect.getattr_static` in `typing._ProtocolMeta.__instancecheck__` (#103034)
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/3.12.rst | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index 8ab9613..93543cb 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -391,6 +391,17 @@ typing same name on a base class, as per :pep:`698`. (Contributed by Steven Troxler in :gh:`101564`.) +* :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. + (Contributed by Alex Waygood in :gh:`102433`.) + sys --- |