From: Gregory P. Smith Date: Sun, 7 Aug 2016 16:06:27 +0000 (-0700) Subject: Issue #26750: unittest.mock.create_autospec() now works properly for X-Git-Tag: v3.6.0a4~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0d24fd1ae05a2aea84165cf0aae98f75a5203c8;p=thirdparty%2FPython%2Fcpython.git Issue #26750: unittest.mock.create_autospec() now works properly for subclasses of property() and other data descriptors. Removes the never publicly used, never documented unittest.mock.DescriptorTypes tuple. --- d0d24fd1ae05a2aea84165cf0aae98f75a5203c8 diff --cc Lib/unittest/mock.py index 4f91c44c6a77,83e9c46676e8..ed915d26bcce --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@@ -60,14 -60,22 +60,10 @@@ def _is_exception(obj) ) --class _slotted(object): -- __slots__ = ['a'] -- -- -# Do not use this tuple. It was never documented as a public API. -# It will be removed. It has no obvious signs of users on github. --DescriptorTypes = ( -- type(_slotted.a), -- property, --) - - + 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): diff --cc Misc/NEWS index 56c21cb8bee3,e6548c283abb..08053f178a33 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -43,13 -34,8 +43,17 @@@ Core and Builtin Library ------- + - Issue #26750: unittest.mock.create_autospec() now works properly for - subclasses of property() and other data descriptors. ++ subclasses of property() and other data descriptors. Removes the never ++ publicly used, never documented unittest.mock.DescriptorTypes tuple. ++ +- Issue #26754: Undocumented support of general bytes-like objects + as path in compile() and similar functions is now deprecated. + +- Issue #26800: Undocumented support of general bytes-like objects + as paths in os functions is now deprecated. + +- Issue #27661: Added tzinfo keyword argument to datetime.combine. - Issue #27568: Prevent HTTPoxy attack (CVE-2016-1000110). Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates