diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2023-05-04 12:26:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 12:26:23 (GMT) |
commit | ef0df5284f929719b2ef3955b1b569ade0a5193c (patch) | |
tree | a3042bd8ea3e8f877f59222f8695f5aca4a4470d /Parser | |
parent | 55d50d147c953fab37b273bca9ab010f40e067d3 (diff) | |
download | cpython-ef0df5284f929719b2ef3955b1b569ade0a5193c.zip cpython-ef0df5284f929719b2ef3955b1b569ade0a5193c.tar.gz cpython-ef0df5284f929719b2ef3955b1b569ade0a5193c.tar.bz2 |
gh-97556: Raise null bytes syntax error upon null in multiline string (GH-104136)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/tokenizer.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index d2f9fee..7c07d20 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -2301,8 +2301,12 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t /* Get rest of string */ while (end_quote_size != quote_size) { c = tok_nextc(tok); - if (tok->done == E_DECODE) + if (tok->done == E_ERROR) { + return MAKE_TOKEN(ERRORTOKEN); + } + if (tok->done == E_DECODE) { break; + } if (c == EOF || (quote_size == 1 && c == '\n')) { assert(tok->multi_line_start != NULL); // shift the tok_state's location into @@ -2554,6 +2558,9 @@ f_string_middle: while (end_quote_size != current_tok->f_string_quote_size) { int c = tok_nextc(tok); + if (tok->done == E_ERROR) { + return MAKE_TOKEN(ERRORTOKEN); + } if (c == EOF || (current_tok->f_string_quote_size == 1 && c == '\n')) { if (tok->decoding_erred) { return MAKE_TOKEN(ERRORTOKEN); |