mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-99606: Make code generated for an empty f-string identical to that of a normal empty string (#112407)
This commit is contained in:
parent
418d585feb
commit
fb202af447
3 changed files with 18 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue