[Python-checkins] gh-91595: fix the comparison of character and integer by using ord() (GH-91596)

miss-islington webhook-mailer at python.org
Sat Apr 16 10:57:15 EDT 2022


https://github.com/python/cpython/commit/c171d757f3892263e163eddd702ae5249308404d
commit: c171d757f3892263e163eddd702ae5249308404d
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-04-16T07:57:07-07:00
summary:

gh-91595: fix the comparison of character and integer by using ord() (GH-91596)


* fix the comparison of character and integer by using ord()

* 📜🤖 Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit 9300b6d72948b94c0924a75ea14c6298156522d0)

Co-authored-by: Yu Liu <yuki.liu at utexas.edu>

files:
A Misc/NEWS.d/next/Library/2022-04-16-05-12-13.gh-issue-91595.CocJBv.rst
M Tools/gdb/libpython.py

diff --git a/Misc/NEWS.d/next/Library/2022-04-16-05-12-13.gh-issue-91595.CocJBv.rst b/Misc/NEWS.d/next/Library/2022-04-16-05-12-13.gh-issue-91595.CocJBv.rst
new file mode 100644
index 0000000000000..637079a6487a4
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-04-16-05-12-13.gh-issue-91595.CocJBv.rst
@@ -0,0 +1 @@
+Fix the comparison of character and integer inside :func:`Tools.gdb.libpython.write_repr`. Patch by Yu Liu.
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 45be5ab9bb9b3..cc0cd2fd1f768 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -1285,7 +1285,7 @@ def write_repr(self, out, visited):
                 out.write('\\r')
 
             # Map non-printable US ASCII to '\xhh' */
-            elif ch < ' ' or ch == 0x7F:
+            elif ch < ' ' or ord(ch) == 0x7F:
                 out.write('\\x')
                 out.write(hexdigits[(ord(ch) >> 4) & 0x000F])
                 out.write(hexdigits[ord(ch) & 0x000F])



More information about the Python-checkins mailing list