mirror of
https://github.com/python/cpython.git
synced 2025-07-13 06:15:17 +00:00
Issue #19030: final pieces for proper location of various class attributes located in the metaclass.
Okay, hopefully the very last patch for this issue. :/ I realized when playing with Enum that the metaclass attributes weren't always displayed properly. New patch properly locates DynamicClassAttributes, virtual class attributes (returned by __getattr__ and friends), and metaclass class attributes (if they are also in the metaclass __dir__ method). Also had to change one line in pydoc to get this to work. Added tests in test_inspect and test_pydoc to cover these situations.
This commit is contained in:
parent
c93dbe2f9b
commit
b0c84cdaac
4 changed files with 226 additions and 31 deletions
|
@ -1235,8 +1235,9 @@ location listed above.
|
|||
doc = getdoc(value)
|
||||
else:
|
||||
doc = None
|
||||
push(self.docother(getattr(object, name),
|
||||
name, mod, maxlen=70, doc=doc) + '\n')
|
||||
push(self.docother(
|
||||
getattr(object, name, None) or homecls.__dict__[name],
|
||||
name, mod, maxlen=70, doc=doc) + '\n')
|
||||
return attrs
|
||||
|
||||
attrs = [(name, kind, cls, value)
|
||||
|
@ -1258,7 +1259,6 @@ location listed above.
|
|||
else:
|
||||
tag = "inherited from %s" % classname(thisclass,
|
||||
object.__module__)
|
||||
|
||||
# Sort attrs by name.
|
||||
attrs.sort()
|
||||
|
||||
|
@ -1273,6 +1273,7 @@ location listed above.
|
|||
lambda t: t[1] == 'data descriptor')
|
||||
attrs = spilldata("Data and other attributes %s:\n" % tag, attrs,
|
||||
lambda t: t[1] == 'data')
|
||||
|
||||
assert attrs == []
|
||||
attrs = inherited
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue