diff Tools/gdb/libpython.py @ 83254:91a57079afbb

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.
author Victor Stinner <victor.stinner@gmail.com>
date Thu, 11 Apr 2013 21:37:45 +0200
parents 07488c3c85f1
children 6d971b172389
line wrap: on
line diff
--- a/Tools/gdb/libpython.py	Thu Apr 11 21:02:20 2013 +0200
+++ b/Tools/gdb/libpython.py	Thu Apr 11 21:37:45 2013 +0200
@@ -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):