mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
2b2fe94cde
commit
c6c1f478d9
3 changed files with 10 additions and 7 deletions
12
Lib/pydoc.py
12
Lib/pydoc.py
|
@ -113,16 +113,16 @@ def cram(text, maxlen):
|
|||
return text[:pre] + '...' + text[len(text)-post:]
|
||||
return text
|
||||
|
||||
_re_stripid = re.compile(r' at 0x[0-9a-f]{6,}(>+)$', re.IGNORECASE)
|
||||
def stripid(text):
|
||||
"""Remove the hexadecimal id from a Python object representation."""
|
||||
# The behaviour of %p is implementation-dependent; we check two cases.
|
||||
for pattern in [' at 0x[0-9a-f]{6,}(>+)$', ' at [0-9A-F]{8,}(>+)$']:
|
||||
if re.search(pattern, repr(Exception)):
|
||||
return re.sub(pattern, '\\1', text)
|
||||
# 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
|
||||
|
||||
def _is_some_method(object):
|
||||
return inspect.ismethod(object) or inspect.ismethoddescriptor(object)
|
||||
def _is_some_method(obj):
|
||||
return inspect.ismethod(obj) or inspect.ismethoddescriptor(obj)
|
||||
|
||||
def allmethods(cl):
|
||||
methods = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue