diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2024-07-26 16:29:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-26 16:29:41 (GMT) |
commit | db2d8b6db1b56c2bd3802b86f9b76da33e8898d7 (patch) | |
tree | 04f846858853c92911b587413628f2162fa6e53e /Parser | |
parent | 7c2921844f9fa713f93152bf3a569812cee347a0 (diff) | |
download | cpython-db2d8b6db1b56c2bd3802b86f9b76da33e8898d7.zip cpython-db2d8b6db1b56c2bd3802b86f9b76da33e8898d7.tar.gz cpython-db2d8b6db1b56c2bd3802b86f9b76da33e8898d7.tar.bz2 |
gh-122300: Preserve AST nodes for format specifiers with single elements (#122308)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/action_helpers.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c index db6f872..1972c60 100644 --- a/Parser/action_helpers.c +++ b/Parser/action_helpers.c @@ -1010,7 +1010,8 @@ _PyPegen_setup_full_format_spec(Parser *p, Token *colon, asdl_expr_seq *spec, in spec = resized_spec; } expr_ty res; - if (asdl_seq_LEN(spec) == 0) { + Py_ssize_t n = asdl_seq_LEN(spec); + if (n == 0 || (n == 1 && asdl_seq_GET(spec, 0)->kind == Constant_kind)) { res = _PyAST_JoinedStr(spec, lineno, col_offset, end_lineno, end_col_offset, p->arena); } else { |