[Python-checkins] gh-91924: Fix __lltrace__ for non-UTF-8 stdout encoding (GH-93199)

miss-islington webhook-mailer at python.org
Wed May 25 06:12:18 EDT 2022


https://github.com/python/cpython/commit/307dacd651356d7318d5330b98794560329cf5e2
commit: 307dacd651356d7318d5330b98794560329cf5e2
branch: 3.11
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-05-25T03:11:46-07:00
summary:

gh-91924: Fix __lltrace__ for non-UTF-8 stdout encoding (GH-93199)


Fix __lltrace__ debug feature if the stdout encoding is not UTF-8.

If the stdout encoding is not UTF-8, the first call to
lltrace_resume_frame() indirectly sets lltrace to 0 when calling
unicode_check_encoding_errors() which calls
encodings.search_function().
(cherry picked from commit 5695c0e0a25da58dfc1d22fc1cd68c2fda0a320d)

Co-authored-by: Victor Stinner <vstinner at python.org>

files:
A Misc/NEWS.d/next/Core and Builtins/2022-05-25-04-07-22.gh-issue-91924.-UyO4q.rst
M Python/ceval.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-05-25-04-07-22.gh-issue-91924.-UyO4q.rst b/Misc/NEWS.d/next/Core and Builtins/2022-05-25-04-07-22.gh-issue-91924.-UyO4q.rst
new file mode 100644
index 0000000000000..44866a03cf48b
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-05-25-04-07-22.gh-issue-91924.-UyO4q.rst	
@@ -0,0 +1,2 @@
+Fix ``__lltrace__`` debug feature if the stdout encoding is not UTF-8. Patch
+by Victor Stinner.
diff --git a/Python/ceval.c b/Python/ceval.c
index c73218fcf307e..62379b4a85527 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -103,7 +103,6 @@ static PyObject * do_call_core(
     PyObject *callargs, PyObject *kwdict, int use_tracing);
 
 #ifdef LLTRACE
-static int lltrace;
 static void
 dump_stack(_PyInterpreterFrame *frame, PyObject **stack_pointer)
 {
@@ -1715,6 +1714,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
     uint8_t opcode;        /* Current opcode */
     int oparg;         /* Current opcode argument, if any */
     _Py_atomic_int * const eval_breaker = &tstate->interp->ceval.eval_breaker;
+#ifdef LLTRACE
+    int lltrace = 0;
+#endif
 
     _PyCFrame cframe;
     CallShape call_shape;



More information about the Python-checkins mailing list