summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-19 01:22:07 +0000
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-19 01:22:07 +0000
commitaedc66768fa6db278693fa02239a081858493425 (patch)
tree8a6c2896b813e27ab721c093b80ccb0e7dd88cc9 /Python/pythonrun.c
parent4f8fc1567ecca1c9ac10931674fda912e5bdc157 (diff)
downloadcpython-aedc66768fa6db278693fa02239a081858493425.tar.gz
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/pythonrun.c')
-rw-r--r--Python/pythonrun.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 84d72f0714..d08d0edd13 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1160,7 +1160,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
d = PyModule_GetDict(m);
if (PyDict_GetItemString(d, "__file__") == NULL) {
PyObject *f;
- f = PyUnicode_FromString(filename);
+ f = PyUnicode_DecodeFSDefault(filename);
if (f == NULL)
return -1;
if (PyDict_SetItemString(d, "__file__", f) < 0) {
@@ -1911,7 +1911,9 @@ err_input(perrdetail *err)
{
PyObject *v, *w, *errtype, *errtext;
PyObject* u = NULL;
+ PyObject *filename;
char *msg = NULL;
+
errtype = PyExc_SyntaxError;
switch (err->error) {
case E_ERROR:
@@ -2000,8 +2002,17 @@ err_input(perrdetail *err)
errtext = PyUnicode_DecodeUTF8(err->text, strlen(err->text),
"replace");
}
- v = Py_BuildValue("(ziiN)", err->filename,
- err->lineno, err->offset, errtext);
+ if (err->filename != NULL)
+ filename = PyUnicode_DecodeFSDefault(err->filename);
+ else {
+ Py_INCREF(Py_None);
+ filename = Py_None;
+ }
+ if (filename != NULL)
+ v = Py_BuildValue("(NiiN)", filename,
+ err->lineno, err->offset, errtext);
+ else
+ v = NULL;
w = NULL;
if (v != NULL)
w = Py_BuildValue("(sO)", msg, v);