Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 65536:42b84d3188d1 3.1
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).
........
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Tue, 19 Oct 2010 01:22:07 +0000 |
| parents | 77c6f60a1b24 |
| children | 902f577e7f94 |
comparison
equal
deleted
inserted
replaced
| 65523:b0ba7eeb98a5 | 65536:42b84d3188d1 |
|---|---|
| 1158 if (m == NULL) | 1158 if (m == NULL) |
| 1159 return -1; | 1159 return -1; |
| 1160 d = PyModule_GetDict(m); | 1160 d = PyModule_GetDict(m); |
| 1161 if (PyDict_GetItemString(d, "__file__") == NULL) { | 1161 if (PyDict_GetItemString(d, "__file__") == NULL) { |
| 1162 PyObject *f; | 1162 PyObject *f; |
| 1163 f = PyUnicode_FromString(filename); | 1163 f = PyUnicode_DecodeFSDefault(filename); |
| 1164 if (f == NULL) | 1164 if (f == NULL) |
| 1165 return -1; | 1165 return -1; |
| 1166 if (PyDict_SetItemString(d, "__file__", f) < 0) { | 1166 if (PyDict_SetItemString(d, "__file__", f) < 0) { |
| 1167 Py_DECREF(f); | 1167 Py_DECREF(f); |
| 1168 return -1; | 1168 return -1; |
| 1909 static void | 1909 static void |
| 1910 err_input(perrdetail *err) | 1910 err_input(perrdetail *err) |
| 1911 { | 1911 { |
| 1912 PyObject *v, *w, *errtype, *errtext; | 1912 PyObject *v, *w, *errtype, *errtext; |
| 1913 PyObject* u = NULL; | 1913 PyObject* u = NULL; |
| 1914 PyObject *filename; | |
| 1914 char *msg = NULL; | 1915 char *msg = NULL; |
| 1916 | |
| 1915 errtype = PyExc_SyntaxError; | 1917 errtype = PyExc_SyntaxError; |
| 1916 switch (err->error) { | 1918 switch (err->error) { |
| 1917 case E_ERROR: | 1919 case E_ERROR: |
| 1918 return; | 1920 return; |
| 1919 case E_SYNTAX: | 1921 case E_SYNTAX: |
| 1998 Py_INCREF(Py_None); | 2000 Py_INCREF(Py_None); |
| 1999 } else { | 2001 } else { |
| 2000 errtext = PyUnicode_DecodeUTF8(err->text, strlen(err->text), | 2002 errtext = PyUnicode_DecodeUTF8(err->text, strlen(err->text), |
| 2001 "replace"); | 2003 "replace"); |
| 2002 } | 2004 } |
| 2003 v = Py_BuildValue("(ziiN)", err->filename, | 2005 if (err->filename != NULL) |
| 2004 err->lineno, err->offset, errtext); | 2006 filename = PyUnicode_DecodeFSDefault(err->filename); |
| 2007 else { | |
| 2008 Py_INCREF(Py_None); | |
| 2009 filename = Py_None; | |
| 2010 } | |
| 2011 if (filename != NULL) | |
| 2012 v = Py_BuildValue("(NiiN)", filename, | |
| 2013 err->lineno, err->offset, errtext); | |
| 2014 else | |
| 2015 v = NULL; | |
| 2005 w = NULL; | 2016 w = NULL; |
| 2006 if (v != NULL) | 2017 if (v != NULL) |
| 2007 w = Py_BuildValue("(sO)", msg, v); | 2018 w = Py_BuildValue("(sO)", msg, v); |
| 2008 Py_XDECREF(u); | 2019 Py_XDECREF(u); |
| 2009 Py_XDECREF(v); | 2020 Py_XDECREF(v); |
