aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/compile.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-11-26 17:13:57 +0000
committerGitHub <noreply@github.com>2023-11-26 17:13:57 +0000
commitfb202af4470d6051a69bb9d2f44d7e8a1c99eb4f (patch)
tree6f643f213d787093de62274fe645ccb0963e8f79 /Python/compile.c
parent418d585febd280e779274f313f910613ac1a1c30 (diff)
downloadcpython-fb202af4470d6051a69bb9d2f44d7e8a1c99eb4f.tar.gz
cpython-fb202af4470d6051a69bb9d2f44d7e8a1c99eb4f.zip
gh-99606: Make code generated for an empty f-string identical to that of a normal empty string (#112407)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 8b1eef79a79..8b9e2f02048 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -5042,8 +5042,12 @@ compiler_joined_str(struct compiler *c, expr_ty e)
}
else {
VISIT_SEQ(c, expr, e->v.JoinedStr.values);
- if (asdl_seq_LEN(e->v.JoinedStr.values) != 1) {
- ADDOP_I(c, loc, BUILD_STRING, asdl_seq_LEN(e->v.JoinedStr.values));
+ if (value_count > 1) {
+ ADDOP_I(c, loc, BUILD_STRING, value_count);
+ }
+ else if (value_count == 0) {
+ _Py_DECLARE_STR(empty, "");
+ ADDOP_LOAD_CONST_NEW(c, loc, Py_NewRef(&_Py_STR(empty)));
}
}
return SUCCESS;