summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2013-10-21 05:37:39 (GMT)
committerEthan Furman <ethan@stoneleaf.us>2013-10-21 05:37:39 (GMT)
commitb0c84cdaac987e075099ac65a218505e9efbdda3 (patch)
treea960c83f11a9a52c4b9036d892c96ce3ed26e392 /Lib/pydoc.py
parentc93dbe2f9b73a00b114e21564b32545898ef356c (diff)
downloadcpython-b0c84cdaac987e075099ac65a218505e9efbdda3.zip
cpython-b0c84cdaac987e075099ac65a218505e9efbdda3.tar.gz
cpython-b0c84cdaac987e075099ac65a218505e9efbdda3.tar.bz2
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.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 174311c..d0240ff 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -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