summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-22 22:41:19 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-22 22:41:19 (GMT)
commitc68b6aaec8b08caf682ebb7c95f94ddf49a6b66c (patch)
treea282727782624c5d77359ac82c6ab9b7b4bc4886 /Parser
parent5569e9b1507ac0ff18fec433a7733a0185dde7b0 (diff)
downloadcpython-c68b6aaec8b08caf682ebb7c95f94ddf49a6b66c.zip
cpython-c68b6aaec8b08caf682ebb7c95f94ddf49a6b66c.tar.gz
cpython-c68b6aaec8b08caf682ebb7c95f94ddf49a6b66c.tar.bz2
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.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 3f6be2f..5ba12a4 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -586,7 +586,10 @@ 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. */
- 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' "