diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-19 01:22:07 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-19 01:22:07 (GMT) |
commit | 15244f7b126b2eab94a0755a82c431a4933330f4 (patch) | |
tree | 358c60d119546f862a90692fd71feaa9c774d78c /Python/ast.c | |
parent | 089144e511ca4b388ce8b29ecf2965a8215ff238 (diff) | |
download | cpython-15244f7b126b2eab94a0755a82c431a4933330f4.zip cpython-15244f7b126b2eab94a0755a82c431a4933330f4.tar.gz cpython-15244f7b126b2eab94a0755a82c431a4933330f4.tar.bz2 |
Recorded merge of revisions 85569-85570 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85569 | victor.stinner | 2010-10-16 15:14:10 +0200 (sam., 16 oct. 2010) | 4 lines
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.
........
r85570 | victor.stinner | 2010-10-16 15:42:53 +0200 (sam., 16 oct. 2010) | 4 lines
Fix ast_error_finish() and err_input(): filename can be NULL
Fix my previous commit (r85569).
........
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c index 5c17133..590bc90 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, *loc, *tmp; + PyObject *filename_obj; long lineno; assert(PyErr_Occurred()); @@ -125,7 +126,16 @@ ast_error_finish(const char *filename) Py_INCREF(Py_None); loc = Py_None; } - tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc); + if (filename != NULL) + filename_obj = PyUnicode_DecodeFSDefault(filename); + else { + Py_INCREF(Py_None); + filename_obj = Py_None; + } + if (filename_obj != NULL) + tmp = Py_BuildValue("(NlOO)", filename_obj, lineno, Py_None, loc); + else + tmp = NULL; Py_DECREF(loc); if (!tmp) { Py_DECREF(errstr); |