diff options
author | Jan Kaliszewski <zuo@kaliszewski.net> | 2024-06-18 12:19:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 12:19:43 (GMT) |
commit | dacc5ac71a8e546f9ef76805827cb50d4d40cabf (patch) | |
tree | bcd0f024d0266970d7edbbbb55a5ead46044b966 /Doc/library/inspect.rst | |
parent | 7c5da94b5d674e112dc77f6494463014b7137193 (diff) | |
download | cpython-dacc5ac71a8e546f9ef76805827cb50d4d40cabf.zip cpython-dacc5ac71a8e546f9ef76805827cb50d4d40cabf.tar.gz cpython-dacc5ac71a8e546f9ef76805827cb50d4d40cabf.tar.bz2 |
gh-120381: Fix inspect.ismethoddescriptor() (#120383)
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.
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/library/inspect.rst')
-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) |