summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-16 13:14:10 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-16 13:14:10 (GMT)
commit4c7c8c30235e42c47500b91549c2b6154b61f883 (patch)
tree649a94a99ea257c19a3e5ba17fc05a8044459243 /Python/ast.c
parent5a7913eb3bf390a2f3fd28116fc789bf2c7e4b64 (diff)
downloadcpython-4c7c8c30235e42c47500b91549c2b6154b61f883.zip
cpython-4c7c8c30235e42c47500b91549c2b6154b61f883.tar.gz
cpython-4c7c8c30235e42c47500b91549c2b6154b61f883.tar.bz2
Issue #9713, #10114: Parser functions (eg. PyParser_ASTFromFile) expects
filenames encoded to the filesystem encoding with surrogateescape error handler (to support undecodable bytes), instead of UTF-8 in strict mode.
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 38643f6..b9beef8 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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);