summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-12-21 10:16:14 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2011-12-21 10:16:14 +0100
commitb8572a1673a8bf25adf3b054f76315bdac2ea45e (patch)
tree06f3a57e3f9b16698b1a3ed13a110c084b7ff51d /Lib/pydoc.py
parent587c7381c76986d0ca51a574f249f06959b93f2c (diff)
downloadcpython-git-b8572a1673a8bf25adf3b054f76315bdac2ea45e.tar.gz
Issue #1785: Fix inspect and pydoc with misbehaving descriptors.
Also fixes issue #13581: `help(type)` wouldn't display anything.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index d55779022f..19a71d8304 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -740,8 +740,15 @@ class HTMLDoc(Doc):
hr.maybe()
push(msg)
for name, kind, homecls, value in ok:
- push(self.document(getattr(object, name), name, mod,
- funcs, classes, mdict, object))
+ try:
+ value = getattr(object, name)
+ except Exception:
+ # Some descriptors may meet a failure in their __get__.
+ # (bug #1785)
+ push(self._docdescriptor(name, value, mod))
+ else:
+ push(self.document(value, name, mod,
+ funcs, classes, mdict, object))
push('\n')
return attrs
@@ -781,7 +788,12 @@ class HTMLDoc(Doc):
mdict = {}
for key, kind, homecls, value in attrs:
mdict[key] = anchor = '#' + name + '-' + key
- value = getattr(object, key)
+ try:
+ value = getattr(object, name)
+ except Exception:
+ # Some descriptors may meet a failure in their __get__.
+ # (bug #1785)
+ pass
try:
# The value may not be hashable (e.g., a data attr with
# a dict or list value).
@@ -1161,8 +1173,15 @@ class TextDoc(Doc):
hr.maybe()
push(msg)
for name, kind, homecls, value in ok:
- push(self.document(getattr(object, name),
- name, mod, object))
+ try:
+ value = getattr(object, name)
+ except Exception:
+ # Some descriptors may meet a failure in their __get__.
+ # (bug #1785)
+ push(self._docdescriptor(name, value, mod))
+ else:
+ push(self.document(value,
+ name, mod, object))
return attrs
def spilldescriptors(msg, attrs, predicate):