File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
python_toolbox/cute_inspect Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1313
1414###############################################################################
1515
16- # Copied from in-development Python 3.4, for the sake of `getattr_static`:
16+ # Copied from in-development Python 3.4, with changes from PyPy, for the sake
17+ # of `getattr_static`:
1718
1819_sentinel = object ()
1920
@@ -45,17 +46,24 @@ def _is_type(obj):
4546 return False
4647 return True
4748
49+ _dict_attr = type .__dict__ ["__dict__" ]
50+ if hasattr (_dict_attr , "__objclass__" ):
51+ _objclass_check = lambda d , entry : d .__objclass__ is entry
52+ else :
53+ # PyPy __dict__ descriptors are 'generic' and lack __objclass__
54+ _objclass_check = lambda d , entry : not hasattr (d , "__objclass__" )
55+
56+
4857def _shadowed_dict (klass ):
49- dict_attr = type .__dict__ ["__dict__" ]
5058 for entry in _static_getmro (klass ):
5159 try :
52- class_dict = dict_attr .__get__ (entry )["__dict__" ]
60+ class_dict = _dict_attr .__get__ (entry )["__dict__" ]
5361 except KeyError :
5462 pass
5563 else :
5664 if not (type (class_dict ) is types .GetSetDescriptorType and
5765 class_dict .__name__ == "__dict__" and
58- class_dict . __objclass__ is entry ):
66+ _objclass_check ( class_dict , entry ) ):
5967 return class_dict
6068 return _sentinel
6169
You can’t perform that action at this time.
0 commit comments