[3.10] gh-91924: Fix __ltrace__ for non-UTF-8 stdout encoding (#93214)

Fix __ltrace__ 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().

Add test_lltrace.test_lltrace() test.
This commit is contained in:
Victor Stinner 2022-05-26 00:16:32 +02:00 committed by GitHub
parent 02d35fc4ef
commit 9369942054
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 2 deletions

View file

@ -5377,6 +5377,8 @@ prtrace(PyThreadState *tstate, PyObject *v, const char *str)
}
printf("\n");
PyErr_Restore(type, value, traceback);
// gh-91924: PyObject_Print() can indirectly set lltrace to 0
lltrace = 1;
return 1;
}
#endif