]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91595: fix the comparison of character and integer by using ord() (#91596)
authorYu Liu <yuki.liu@utexas.edu>
Sat, 16 Apr 2022 14:34:48 +0000 (09:34 -0500)
committerGitHub <noreply@github.com>
Sat, 16 Apr 2022 14:34:48 +0000 (16:34 +0200)
* 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>
Misc/NEWS.d/next/Library/2022-04-16-05-12-13.gh-issue-91595.CocJBv.rst [new file with mode: 0644]
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 (file)
index 0000000..637079a
--- /dev/null
@@ -0,0 +1 @@
+Fix the comparison of character and integer inside :func:`Tools.gdb.libpython.write_repr`. Patch by Yu Liu.
index 4f7a8bca5fd786c373b6e287ebb78711c6793aee..610d13099432cdb01faddfe0cde8e5c7ce97bf1a 100755 (executable)
@@ -1418,7 +1418,7 @@ class PyUnicodeObjectPtr(PyObjectPtr):
                 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])