[Python-checkins] cpython (merge 3.2 -> default): Correctly merging #9319 into 3.3?
jesus.cea
python-checkins at python.org
Mon Apr 25 03:48:00 CEST 2011
http://hg.python.org/cpython/rev/bb62908896fe
changeset: 69548:bb62908896fe
parent: 69544:996b9c9dc10a
parent: 69541:b0385ec55e7e
user: Jesus Cea <jcea at jcea.es>
date: Mon Apr 25 03:46:43 2011 +0200
summary:
Correctly merging #9319 into 3.3?
files:
Lib/test/test_imp.py | 4 ++++
Parser/tokenizer.c | 19 +++++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -176,6 +176,10 @@
support.unlink(init_file_name + ext)
support.rmtree(test_package_name)
+ def test_issue9319(self):
+ self.assertRaises(SyntaxError,
+ imp.find_module, "test/badsyntax_pep3120")
+
class ReloadTests(unittest.TestCase):
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -585,12 +585,19 @@
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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list