summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-06-27 15:45:41 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-06-27 15:45:41 (GMT)
commit0fe8fce7e3de8549ae4a26cfe3299872bf2b446c (patch)
tree9e3800e46c5c7b7021c82e7cb75f3c3785e00464 /Lib/pydoc.py
parent896e5164bb8562d0e5daeccd5f9f5f1d03aedeba (diff)
downloadcpython-0fe8fce7e3de8549ae4a26cfe3299872bf2b446c.zip
cpython-0fe8fce7e3de8549ae4a26cfe3299872bf2b446c.tar.gz
cpython-0fe8fce7e3de8549ae4a26cfe3299872bf2b446c.tar.bz2
(HTML|Text)Repr.repr1: Guard against objects whos types have no __name__
attribute. Patch and bug report from Geoff Talvola. Closes patch #672855.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index abafc0e..410d921 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -312,11 +312,11 @@ class HTMLRepr(Repr):
return Repr.repr(self, object)
def repr1(self, x, level):
- methodname = 'repr_' + join(split(type(x).__name__), '_')
- if hasattr(self, methodname):
- return getattr(self, methodname)(x, level)
- else:
- return self.escape(cram(stripid(repr(x)), self.maxother))
+ if hasattr(type(x), '__name__'):
+ methodname = 'repr_' + join(split(type(x).__name__), '_')
+ if hasattr(self, methodname):
+ return getattr(self, methodname)(x, level)
+ return self.escape(cram(stripid(repr(x)), self.maxother))
def repr_string(self, x, level):
test = cram(x, self.maxstring)
@@ -874,11 +874,11 @@ class TextRepr(Repr):
self.maxstring = self.maxother = 100
def repr1(self, x, level):
- methodname = 'repr_' + join(split(type(x).__name__), '_')
- if hasattr(self, methodname):
- return getattr(self, methodname)(x, level)
- else:
- return cram(stripid(repr(x)), self.maxother)
+ if hasattr(type(x), '__name__'):
+ methodname = 'repr_' + join(split(type(x).__name__), '_')
+ if hasattr(self, methodname):
+ return getattr(self, methodname)(x, level)
+ return cram(stripid(repr(x)), self.maxother)
def repr_string(self, x, level):
test = cram(x, self.maxstring)