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 5695c0e0a2)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2022-05-25 03:11:46 -07:00 committed by GitHub
parent 2ea3d3b847
commit 307dacd651
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -0,0 +1,2 @@
Fix ``__lltrace__`` debug feature if the stdout encoding is not UTF-8. Patch
by Victor Stinner.

View file

@ -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;