[Python-checkins] cpython: python-gdb.py: Replace invalid Unicode character with U+FFFD to be able to
victor.stinner
python-checkins at python.org
Thu Apr 11 21:39:57 CEST 2013
http://hg.python.org/cpython/rev/91a57079afbb
changeset: 83254:91a57079afbb
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Apr 11 21:37:45 2013 +0200
summary:
python-gdb.py: Replace invalid Unicode character with U+FFFD to be able to
display invalid strings. Such strings can be found while Python is creating a
new string, in a text decoder for example, when Python is compiled in debug
mode.
files:
Tools/gdb/libpython.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -1160,7 +1160,9 @@
# Convert the int code points to unicode characters, and generate a
# local unicode instance.
# This splits surrogate pairs if sizeof(Py_UNICODE) is 2 here (in gdb).
- result = u''.join([_unichr(ucs) for ucs in Py_UNICODEs])
+ result = u''.join([
+ (_unichr(ucs) if ucs <= 0x10ffff else '\ufffd')
+ for ucs in Py_UNICODEs])
return result
def write_repr(self, out, visited):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list