summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2023-06-15 16:21:24 (GMT)
committerGitHub <noreply@github.com>2023-06-15 16:21:24 (GMT)
commitd382ad49157b3802fc5619f68d96810def517869 (patch)
treea17121aac146c3797007502c55b6c105d298c7f2 /Parser
parent8f10140e74d141a0a894702044e213e6f0690d9c (diff)
downloadcpython-d382ad49157b3802fc5619f68d96810def517869.zip
cpython-d382ad49157b3802fc5619f68d96810def517869.tar.gz
cpython-d382ad49157b3802fc5619f68d96810def517869.tar.bz2
gh-105820: Fix tok_mode expression buffer in file & readline tokenizer (#105828)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/tokenizer.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 5d01b8e..4f7b1f8 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -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. */