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 0000000000000000000000000000000000000000..44866a03cf48b1a8810ccd28b8812f201ddb33af
--- /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 230198b41f6a54192dadd785189db9ec270164dc..e82f7343022165045f6b12ee020b1c2ecdddb4fd 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -107,7 +107,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;