mirror of https://github.com/python/cpython
Correctly merging #9319 into 3.3?
This commit is contained in:
commit
88f7841be7
|
@ -176,6 +176,10 @@ class ImportTests(unittest.TestCase):
|
||||||
support.unlink(init_file_name + ext)
|
support.unlink(init_file_name + ext)
|
||||||
support.rmtree(test_package_name)
|
support.rmtree(test_package_name)
|
||||||
|
|
||||||
|
def test_issue9319(self):
|
||||||
|
self.assertRaises(SyntaxError,
|
||||||
|
imp.find_module, "test/badsyntax_pep3120")
|
||||||
|
|
||||||
|
|
||||||
class ReloadTests(unittest.TestCase):
|
class ReloadTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -585,12 +585,19 @@ decoding_fgets(char *s, int size, struct tok_state *tok)
|
||||||
if (badchar) {
|
if (badchar) {
|
||||||
/* Need to add 1 to the line number, since this line
|
/* Need to add 1 to the line number, since this line
|
||||||
has not been counted, yet. */
|
has not been counted, yet. */
|
||||||
PyErr_Format(PyExc_SyntaxError,
|
if (tok->filename != NULL)
|
||||||
"Non-UTF-8 code starting with '\\x%.2x' "
|
filename = PyUnicode_DecodeFSDefault(tok->filename);
|
||||||
"in file %U on line %i, "
|
else
|
||||||
"but no encoding declared; "
|
filename = PyUnicode_FromString("<file>");
|
||||||
"see http://python.org/dev/peps/pep-0263/ for details",
|
if (filename != NULL) {
|
||||||
badchar, tok->filename, tok->lineno + 1);
|
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);
|
return error_ret(tok);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue