diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-06-19 07:01:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 07:01:09 (GMT) |
commit | 39c3f11f2552f751d7d484d9e27222bcb0a3672e (patch) | |
tree | 6d8ca481fa64a3e4250ee844ea0b7e32874fd6b1 /Doc | |
parent | a22eb2f2666c6f0a0ddef7b918222936c71c1ee5 (diff) | |
download | cpython-39c3f11f2552f751d7d484d9e27222bcb0a3672e.zip cpython-39c3f11f2552f751d7d484d9e27222bcb0a3672e.tar.gz cpython-39c3f11f2552f751d7d484d9e27222bcb0a3672e.tar.bz2 |
[3.13] gh-120381: Fix inspect.ismethoddescriptor() (GH-120684)
The `inspect.ismethoddescriptor()` function did not check for the lack of
`__delete__()` and, consequently, erroneously returned True when applied
to *data* descriptors with only `__get__()` and `__delete__()` defined.
(cherry picked from commit dacc5ac71a8e546f9ef76805827cb50d4d40cabf)
Co-authored-by: Jan Kaliszewski <zuo@kaliszewski.net>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/inspect.rst | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 7130faa..0ec7d7c 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -504,9 +504,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes): are true. This, for example, is true of ``int.__add__``. An object passing this test - has a :meth:`~object.__get__` method but not a :meth:`~object.__set__` - method, but beyond that the set of attributes varies. A - :attr:`~definition.__name__` attribute is usually + has a :meth:`~object.__get__` method, but not a :meth:`~object.__set__` + method or a :meth:`~object.__delete__` method. Beyond that, the set of + attributes varies. A :attr:`~definition.__name__` attribute is usually sensible, and :attr:`!__doc__` often is. Methods implemented via descriptors that also pass one of the other tests @@ -515,6 +515,11 @@ attributes (see :ref:`import-mod-attrs` for module attributes): :attr:`~method.__func__` attribute (etc) when an object passes :func:`ismethod`. + .. versionchanged:: 3.13 + This function no longer incorrectly reports objects with :meth:`~object.__get__` + and :meth:`~object.__delete__`, but not :meth:`~object.__set__`, as being method + descriptors (such objects are data descriptors, not method descriptors). + .. function:: isdatadescriptor(object) |