inspect.classify_class_attrs: Classify object.__new__ and __init__ correctly #18801
This commit is contained in:
parent
28479d8c7d
commit
0860a0bd3f
|
@ -412,7 +412,7 @@ def classify_class_attrs(cls):
|
||||||
elif isinstance(dict_obj, property):
|
elif isinstance(dict_obj, property):
|
||||||
kind = "property"
|
kind = "property"
|
||||||
obj = dict_obj
|
obj = dict_obj
|
||||||
elif isfunction(obj) or ismethoddescriptor(obj):
|
elif isroutine(obj):
|
||||||
kind = "method"
|
kind = "method"
|
||||||
else:
|
else:
|
||||||
kind = "data"
|
kind = "data"
|
||||||
|
|
|
@ -646,6 +646,10 @@ class TestClassesAndFunctions(unittest.TestCase):
|
||||||
md = _BrokenMethodDescriptor()
|
md = _BrokenMethodDescriptor()
|
||||||
|
|
||||||
attrs = attrs_wo_objs(A)
|
attrs = attrs_wo_objs(A)
|
||||||
|
|
||||||
|
self.assertIn(('__new__', 'method', object), attrs, 'missing __new__')
|
||||||
|
self.assertIn(('__init__', 'method', object), attrs, 'missing __init__')
|
||||||
|
|
||||||
self.assertIn(('s', 'static method', A), attrs, 'missing static method')
|
self.assertIn(('s', 'static method', A), attrs, 'missing static method')
|
||||||
self.assertIn(('c', 'class method', A), attrs, 'missing class method')
|
self.assertIn(('c', 'class method', A), attrs, 'missing class method')
|
||||||
self.assertIn(('p', 'property', A), attrs, 'missing property')
|
self.assertIn(('p', 'property', A), attrs, 'missing property')
|
||||||
|
|
Loading…
Reference in New Issue