diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-01-08 22:51:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-08 22:51:29 (GMT) |
commit | bc0a686f820d7d298a0b1450b155a717972de0fc (patch) | |
tree | f4e4f5acefd28c9cb42a4db8631ed0d59165992d /Python/symtable.c | |
parent | 8d69828092f734cd9275459173a0f89bde109659 (diff) | |
download | cpython-bc0a686f820d7d298a0b1450b155a717972de0fc.zip cpython-bc0a686f820d7d298a0b1450b155a717972de0fc.tar.gz cpython-bc0a686f820d7d298a0b1450b155a717972de0fc.tar.bz2 |
gh-87447: Fix walrus comprehension rebind checking (#100581)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Diffstat (limited to 'Python/symtable.c')
-rw-r--r-- | Python/symtable.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/symtable.c b/Python/symtable.c index 3c13018..89a2bc4 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1488,7 +1488,8 @@ symtable_extend_namedexpr_scope(struct symtable *st, expr_ty e) */ if (ste->ste_comprehension) { long target_in_scope = _PyST_GetSymbol(ste, target_name); - if (target_in_scope & DEF_COMP_ITER) { + if ((target_in_scope & DEF_COMP_ITER) && + (target_in_scope & DEF_LOCAL)) { PyErr_Format(PyExc_SyntaxError, NAMED_EXPR_COMP_CONFLICT, target_name); PyErr_RangedSyntaxLocationObject(st->st_filename, e->lineno, |