summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2011-04-25 01:46:43 (GMT)
committerJesus Cea <jcea@jcea.es>2011-04-25 01:46:43 (GMT)
commit88f7841be7c59eea1eb5960b68190e6ca5486daa (patch)
tree64909c198ea97285c7bebf72b4448dcf4853dab8 /Parser
parent762f8d1bf2dcbab7ddc0231efc297caef1818c64 (diff)
parent5db3e0167d63b954af2c996c0eba494d309fb539 (diff)
downloadcpython-88f7841be7c59eea1eb5960b68190e6ca5486daa.zip
cpython-88f7841be7c59eea1eb5960b68190e6ca5486daa.tar.gz
cpython-88f7841be7c59eea1eb5960b68190e6ca5486daa.tar.bz2
Correctly merging #9319 into 3.3?
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index f4d7e3f..f7ca598 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -585,12 +585,19 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
if (badchar) {
/* Need to add 1 to the line number, since this line
has not been counted, yet. */
- PyErr_Format(PyExc_SyntaxError,
- "Non-UTF-8 code starting with '\\x%.2x' "
- "in file %U on line %i, "
- "but no encoding declared; "
- "see http://python.org/dev/peps/pep-0263/ for details",
- badchar, tok->filename, tok->lineno + 1);
+ if (tok->filename != NULL)
+ filename = PyUnicode_DecodeFSDefault(tok->filename);
+ else
+ filename = PyUnicode_FromString("<file>");
+ if (filename != NULL) {
+ PyErr_Format(PyExc_SyntaxError,
+ "Non-UTF-8 code starting with '\\x%.2x' "
+ "in file %U on line %i, "
+ "but no encoding declared; "
+ "see http://python.org/dev/peps/pep-0263/ for details",
+ badchar, filename, tok->lineno + 1);
+ Py_DECREF(filename);
+ }
return error_ret(tok);
}
#endif