[Python-checkins] cpython (merge 3.5 -> default): Issue #26750: use inspect.isdatadescriptor instead of our own

gregory.p.smith python-checkins at python.org
Tue Aug 16 02:56:39 EDT 2016


https://hg.python.org/cpython/rev/d51a66622266
changeset:   102698:d51a66622266
parent:      102696:965a6a5539f2
parent:      102697:3ff02380b1bf
user:        Gregory P. Smith <greg at krypto.org>
date:        Mon Aug 15 23:56:32 2016 -0700
summary:
  Issue #26750: use inspect.isdatadescriptor instead of our own
_is_data_descriptor().

files:
  Lib/unittest/mock.py |  8 +-------
  1 files changed, 1 insertions(+), 7 deletions(-)


diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -60,12 +60,6 @@
     )
 
 
-def _is_data_descriptor(obj):
-    # Data descriptors are Properties, slots, getsets and C data members.
-    return ((hasattr(obj, '__set__') or hasattr(obj, '__del__')) and
-            hasattr(obj, '__get__'))
-
-
 def _get_signature_object(func, as_instance, eat_self):
     """
     Given an arbitrary, possibly callable object, try to create a suitable
@@ -2149,7 +2143,7 @@
     _kwargs.update(kwargs)
 
     Klass = MagicMock
-    if _is_data_descriptor(spec):
+    if inspect.isdatadescriptor(spec):
         # descriptors don't have a spec
         # because we don't know what type they return
         _kwargs = {}

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list