]> granicus.if.org Git - python/commitdiff
Issue #26750: unittest.mock.create_autospec() now works properly for
authorGregory P. Smith <greg@krypto.org>
Sun, 7 Aug 2016 16:06:27 +0000 (09:06 -0700)
committerGregory P. Smith <greg@krypto.org>
Sun, 7 Aug 2016 16:06:27 +0000 (09:06 -0700)
subclasses of property() and other data descriptors.  Removes the never
publicly used, never documented unittest.mock.DescriptorTypes tuple.

1  2 
Lib/unittest/mock.py
Misc/NEWS

index 4f91c44c6a77ffeef7a31d3a3e1785cb2637ee1c,83e9c46676e8b685631e1e4e9797aadfdb721f5e..ed915d26bcceda3cca70039c655b4b0d779fd1b9
@@@ -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 56c21cb8bee37d207185815edb973802d639a1d6,e6548c283abb99907d30a731d202b88ef32c1b65..08053f178a331fdf27f86beea9d9f6c0cc3605a2
+++ b/Misc/NEWS
@@@ -43,13 -34,8 +43,17 @@@ Core and Builtin
  Library
  -------
  
 -  subclasses of property() and other data descriptors.
+ - 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.
++
 +- 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