summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorAaron Hall, MBA <aaronchall@yahoo.com>2018-05-20 23:46:42 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-05-20 23:46:42 (GMT)
commit4054b172ab59054715a2aaf4979bd84ac23e3ada (patch)
treee21f94afd65ee1cd88e011649fd6147f03567a12 /Lib/inspect.py
parentaef639f62677f8a342af24e9c19f0503b0d1e36e (diff)
downloadcpython-4054b172ab59054715a2aaf4979bd84ac23e3ada.zip
cpython-4054b172ab59054715a2aaf4979bd84ac23e3ada.tar.gz
cpython-4054b172ab59054715a2aaf4979bd84ac23e3ada.tar.bz2
bpo-26103: Fix inspect.isdatadescriptor() and a data descriptor definition. (GH-1959)
Look for '__set__' or '__delete__'.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 512785f..e5d312e 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -110,7 +110,7 @@ def ismethoddescriptor(object):
def isdatadescriptor(object):
"""Return true if the object is a data descriptor.
- Data descriptors have both a __get__ and a __set__ attribute. Examples are
+ Data descriptors have a __set__ or a __delete__ attribute. Examples are
properties (defined in Python) and getsets and members (defined in C).
Typically, data descriptors will also have __name__ and __doc__ attributes
(properties, getsets, and members have both of these attributes), but this
@@ -119,7 +119,7 @@ def isdatadescriptor(object):
# mutual exclusion
return False
tp = type(object)
- return hasattr(tp, "__set__") and hasattr(tp, "__get__")
+ return hasattr(tp, "__set__") or hasattr(tp, "__delete__")
if hasattr(types, 'MemberDescriptorType'):
# CPython and equivalent