Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c35a32f

Browse files
committed
Issue #26750: use inspect.isdatadescriptor instead of our own
_is_data_descriptor().
2 parents f050a33 + d4583d7 commit c35a32f

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

Lib/unittest/mock.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ def _is_exception(obj):
6060
)
6161

6262

63-
def _is_data_descriptor(obj):
64-
# Data descriptors are Properties, slots, getsets and C data members.
65-
return ((hasattr(obj, '__set__') or hasattr(obj, '__del__')) and
66-
hasattr(obj, '__get__'))
67-
68-
6963
def _get_signature_object(func, as_instance, eat_self):
7064
"""
7165
Given an arbitrary, possibly callable object, try to create a suitable
@@ -2149,7 +2143,7 @@ def create_autospec(spec, spec_set=False, instance=False, _parent=None,
21492143
_kwargs.update(kwargs)
21502144

21512145
Klass = MagicMock
2152-
if _is_data_descriptor(spec):
2146+
if inspect.isdatadescriptor(spec):
21532147
# descriptors don't have a spec
21542148
# because we don't know what type they return
21552149
_kwargs = {}

0 commit comments

Comments
 (0)