pydoc.stripid() is now case-insensitive for its regex to support platforms that

have pointer addresses in uppercase.

Closes bug #934282.  Thanks Robin Becker.
This commit is contained in:
Brett Cannon 2004-06-19 01:02:51 +00:00
parent 2b2fe94cde
commit c6c1f478d9
3 changed files with 10 additions and 7 deletions

View file

@ -113,16 +113,16 @@ def cram(text, maxlen):
return text[:pre] + '...' + text[len(text)-post:] return text[:pre] + '...' + text[len(text)-post:]
return text return text
_re_stripid = re.compile(r' at 0x[0-9a-f]{6,}(>+)$', re.IGNORECASE)
def stripid(text): def stripid(text):
"""Remove the hexadecimal id from a Python object representation.""" """Remove the hexadecimal id from a Python object representation."""
# The behaviour of %p is implementation-dependent; we check two cases. # The behaviour of %p is implementation-dependent in terms of case.
for pattern in [' at 0x[0-9a-f]{6,}(>+)$', ' at [0-9A-F]{8,}(>+)$']: if _re_stripid.search(repr(Exception)):
if re.search(pattern, repr(Exception)): return _re_stripid.sub(r'\1', text)
return re.sub(pattern, '\\1', text)
return text return text
def _is_some_method(object): def _is_some_method(obj):
return inspect.ismethod(object) or inspect.ismethoddescriptor(object) return inspect.ismethod(obj) or inspect.ismethoddescriptor(obj)
def allmethods(cl): def allmethods(cl):
methods = {} methods = {}

View file

@ -43,6 +43,7 @@ Samuel L. Bayer
Donald Beaudry Donald Beaudry
David Beazley David Beazley
Neal Becker Neal Becker
Robin Becker
Bill Bedford Bill Bedford
Reimer Behrends Reimer Behrends
Thomas Bellman Thomas Bellman

View file

@ -336,6 +336,8 @@ Extension modules
Library Library
------- -------
- Bug #934282: pydoc.stripid() is now case-insensitive. Thanks Robin Becker.
- Bug #823209: cmath.log() now takes an optional base argument so that its - Bug #823209: cmath.log() now takes an optional base argument so that its
API matches math.log(). API matches math.log().