Mercurial > cpython-lru_cache-weakref
diff Parser/tokenizer.c @ 69529:fa5e348889c2 3.2
Issue #9319: Fix a crash on parsing a Python source code without encoding
cookie and not valid in UTF-8: use "<file>" as the filename instead of
reading from NULL.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Sat, 23 Apr 2011 00:41:19 +0200 |
| parents | 3c9232a684ae |
| children | bb62908896fe |
line wrap: on
line diff
--- a/Parser/tokenizer.c Fri Apr 22 01:42:10 2011 +0300 +++ b/Parser/tokenizer.c Sat Apr 23 00:41:19 2011 +0200 @@ -586,7 +586,10 @@ if (badchar) { /* Need to add 1 to the line number, since this line has not been counted, yet. */ - filename = PyUnicode_DecodeFSDefault(tok->filename); + 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' "
