Index: Lib/pydoc.py =================================================================== --- Lib/pydoc.py (revision 78175) +++ Lib/pydoc.py (working copy) @@ -124,7 +124,7 @@ def stripid(text): """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent in terms of case. - if _re_stripid.search(repr(Exception)): + if _re_stripid.search(repr(stripid)): return _re_stripid.sub(r'\1', text) return text Index: Lib/test/test_pydoc.py =================================================================== --- Lib/test/test_pydoc.py (revision 78175) +++ Lib/test/test_pydoc.py (working copy) @@ -291,7 +291,15 @@ "white space was not stripped from module name " "or other error output mismatch") + def test_stripid(self): + stripid = pydoc.stripid + # strip the id from '' + self.assertEqual(stripid(repr(stripid)), '') + # nothing to strip, return the same text + self.assertEqual(stripid(repr(42)), repr(42)) + self.assertEqual(stripid(repr(pydoc)), repr(pydoc)) + class TestDescriptions(unittest.TestCase): def test_module(self):