[3.14] gh-158451: Fix python-gdb.py for invalid Unicode strings (GH-1… · python/cpython@13b1a4b · GitHub
Skip to content

Commit 13b1a4b

Browse files
[3.14] gh-158451: Fix python-gdb.py for invalid Unicode strings (GH-158475) (#158495)
gh-158451: Fix python-gdb.py for invalid Unicode strings (GH-158475) python-gdb.py is now able to format an invalid Unicode string: render invalid characters as "\Uhhhhhhhh" instead of raising an exception. The PyUnicodeWriter API fills a UCS-4 buffer with 0xff byte pattern to detect usage of uninitialized characters. It produces invalid characters '\Uffffffff'. PyBytesObjectPtr now iterates on bytes (list of integers), instead of creating a temporary Unicode string. Add more bytes tests in test_gdb pretty printer. Remove the unused 'ch2' variable. (cherry picked from commit 7eada7c) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 4443885 commit 13b1a4b

3 files changed

Lines changed: 49 additions & 38 deletions

File tree

‎Lib/test/test_gdb/test_pretty_print.py‎

Lines changed: 4 additions & 1 deletion
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``python-gdb.py`` is now able to format an invalid Unicode string: render
2+
invalid characters as ``\Uhhhhhhhh`` instead of raising an exception. Patch by
3+
Victor Stinner.

‎Tools/gdb/libpython.py‎

Lines changed: 42 additions & 37 deletions

0 commit comments

Comments
 (0)