gh-143055: Fix crash in AST unparser when unparsing dict comprehension unpacking (#145556)

This commit is contained in:
Stan Ulbrych 2026-03-09 17:37:23 +00:00 committed by GitHub
parent d76df75f51
commit 255e79fa95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 26 additions and 6 deletions

View file

@ -464,9 +464,15 @@ static int
append_ast_dictcomp(PyUnicodeWriter *writer, expr_ty e)
{
APPEND_CHAR('{');
APPEND_EXPR(e->v.DictComp.key, PR_TEST);
APPEND_STR(": ");
APPEND_EXPR(e->v.DictComp.value, PR_TEST);
if (e->v.DictComp.value) {
APPEND_EXPR(e->v.DictComp.key, PR_TEST);
APPEND_STR(": ");
APPEND_EXPR(e->v.DictComp.value, PR_TEST);
}
else {
APPEND_STR("**");
APPEND_EXPR(e->v.DictComp.key, PR_TEST);
}
APPEND(comprehensions, e->v.DictComp.generators);
APPEND_CHAR_FINISH('}');
}