Take into account encoding of source file for syntax error #124188
Labels
3.12
bugs and security fixes
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
topic-C-API
Currently most syntax errors raised in the compiler (except these raised in the parser) use
PyErr_ProgramTextObject()
to get the line of the code. It does not know the encoding of the source file and interpret it as UTF-8 (failing if it contain non-UTF-8 sequences). The parser uses_PyErr_ProgramDecodedTextObject()
.There are two ways to solve this issue:
PyErr_ProgramTextObject()
. Since the latter is in the public C API, this can also affect the third-party code.There are other issues with
PyErr_ProgramTextObject()
:This all applies to
PyErr_ProgramText()
as well.Linked PRs
The text was updated successfully, but these errors were encountered: