mirror of
https://github.com/python/cpython.git
synced 2025-07-12 05:45:15 +00:00
filenames encoded to the filesystem encoding with surrogateescape error handler (to support undecodable bytes), instead of UTF-8 in strict mode.
This commit is contained in:
parent
5a7913eb3b
commit
4c7c8c3023
7 changed files with 69 additions and 28 deletions
|
@ -102,6 +102,7 @@ static void
|
|||
ast_error_finish(const char *filename)
|
||||
{
|
||||
PyObject *type, *value, *tback, *errstr, *offset, *loc, *tmp;
|
||||
PyObject *filename_obj;
|
||||
long lineno;
|
||||
|
||||
assert(PyErr_Occurred());
|
||||
|
@ -130,7 +131,11 @@ ast_error_finish(const char *filename)
|
|||
Py_INCREF(Py_None);
|
||||
loc = Py_None;
|
||||
}
|
||||
tmp = Py_BuildValue("(zlOO)", filename, lineno, offset, loc);
|
||||
filename_obj = PyUnicode_DecodeFSDefault(filename);
|
||||
if (filename_obj != NULL)
|
||||
tmp = Py_BuildValue("(NlOO)", filename_obj, lineno, offset, loc);
|
||||
else
|
||||
tmp = NULL;
|
||||
Py_DECREF(loc);
|
||||
if (!tmp) {
|
||||
Py_DECREF(errstr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue