[3.12] gh-105820: Fix tok_mode expression buffer in file & readline tokenizer (GH-105828) (#105832)

(cherry picked from commit d382ad4915)

Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-06-15 10:21:58 -07:00 committed by GitHub
parent abb4eaa46f
commit e9cf5a324e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 4 deletions

View file

@ -1039,9 +1039,6 @@ tok_readline_raw(struct tok_state *tok)
if (line == NULL) {
return 1;
}
if (tok->tok_mode_stack_index && !update_fstring_expr(tok, 0)) {
return 0;
}
if (tok->fp_interactive &&
tok_concatenate_interactive_new_line(tok, line) == -1) {
return 0;
@ -1270,6 +1267,10 @@ tok_underflow_file(struct tok_state *tok) {
tok->implicit_newline = 1;
}
if (tok->tok_mode_stack_index && !update_fstring_expr(tok, 0)) {
return 0;
}
ADVANCE_LINENO();
if (tok->decoding_state != STATE_NORMAL) {
if (tok->lineno > 2) {
@ -1314,6 +1315,10 @@ tok_underflow_readline(struct tok_state* tok) {
tok->implicit_newline = 1;
}
if (tok->tok_mode_stack_index && !update_fstring_expr(tok, 0)) {
return 0;
}
ADVANCE_LINENO();
/* The default encoding is UTF-8, so make sure we don't have any
non-UTF-8 sequences in it. */