# HG changeset patch # User Ezio Melotti # Date 1266362984 0 # Node ID eecf1bef052d3da51123d285b83d18b4c41a5e17 # Parent 15b049fac191a4065cb086c8c779577f91955fb6 Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........ diff -r 15b049fac191 -r eecf1bef052d Lib/pydoc.py --- a/Lib/pydoc.py Mon Feb 15 21:43:41 2010 +0000 +++ b/Lib/pydoc.py Tue Feb 16 23:29:44 2010 +0000 @@ -124,9 +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)): - return _re_stripid.sub(r'\1', text) - return text + return _re_stripid.sub(r'\1', text) def _is_some_method(obj): return inspect.ismethod(obj) or inspect.ismethoddescriptor(obj) diff -r 15b049fac191 -r eecf1bef052d Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Mon Feb 15 21:43:41 2010 +0000 +++ b/Lib/test/test_pydoc.py Tue Feb 16 23:29:44 2010 +0000 @@ -288,6 +288,19 @@ "white space was not stripped from module name " "or other error output mismatch") + def test_stripid(self): + # test with strings, other implementations might have different repr() + stripid = pydoc.stripid + # strip the id + self.assertEqual(stripid(''), + '') + self.assertEqual(stripid(''), + '') + # nothing to strip, return the same text + self.assertEqual(stripid('42'), '42') + self.assertEqual(stripid(""), + "") + class TestDescriptions(unittest.TestCase):