mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
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>
This commit is contained in:
parent
8d69828092
commit
bc0a686f82
4 changed files with 92 additions and 3 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue