[Python-checkins] r78207 - in python/trunk/Lib: pydoc.py test/test_pydoc.py
ezio.melotti
python-checkins at python.org
Wed Feb 17 00:26:09 CET 2010
Author: ezio.melotti
Date: Wed Feb 17 00:26:09 2010
New Revision: 78207
Log:
#7930: fix stripid
Modified:
python/trunk/Lib/pydoc.py
python/trunk/Lib/test/test_pydoc.py
Modified: python/trunk/Lib/pydoc.py
==============================================================================
--- python/trunk/Lib/pydoc.py (original)
+++ python/trunk/Lib/pydoc.py Wed Feb 17 00:26:09 2010
@@ -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)
Modified: python/trunk/Lib/test/test_pydoc.py
==============================================================================
--- python/trunk/Lib/test/test_pydoc.py (original)
+++ python/trunk/Lib/test/test_pydoc.py Wed Feb 17 00:26:09 2010
@@ -291,6 +291,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('<function stripid at 0x88dcee4>'),
+ '<function stripid>')
+ self.assertEqual(stripid('<function stripid at 0x01F65390>'),
+ '<function stripid>')
+ # nothing to strip, return the same text
+ self.assertEqual(stripid('42'), '42')
+ self.assertEqual(stripid("<type 'exceptions.Exception'>"),
+ "<type 'exceptions.Exception'>")
+
class TestDescriptions(unittest.TestCase):
More information about the Python-checkins
mailing list