summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-12-21 08:59:49 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-12-21 08:59:49 (GMT)
commit12f65d1fefde68ae142b96075917012a61cb8abf (patch)
treec95cb03a5ada920abd3ca1ae6720ba1cfb201dda /Lib/pydoc.py
parent501da61671f88032cfde9b81060ddd82d22bf8ec (diff)
parent86a8a9ae983b66ea218ccbb57d3e3a5cdf918e97 (diff)
downloadcpython-12f65d1fefde68ae142b96075917012a61cb8abf.zip
cpython-12f65d1fefde68ae142b96075917012a61cb8abf.tar.gz
cpython-12f65d1fefde68ae142b96075917012a61cb8abf.tar.bz2
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 b5dbde6..591717b 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -748,8 +748,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
@@ -790,7 +797,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).
@@ -1177,8 +1189,15 @@ location listed above.
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):