gh-109118: Allow lambdas in annotation scopes in classes (#118019)

This commit is contained in:
Jelle Zijlstra 2024-04-22 12:50:26 -07:00 committed by GitHub
parent 4c7bfdff90
commit 85f727c5fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 53 additions and 13 deletions

View file

@ -2140,17 +2140,6 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
VISIT(st, expr, e->v.UnaryOp.operand);
break;
case Lambda_kind: {
if (st->st_cur->ste_can_see_class_scope) {
// gh-109118
PyErr_Format(PyExc_SyntaxError,
"Cannot use lambda in annotation scope within class scope");
PyErr_RangedSyntaxLocationObject(st->st_filename,
e->lineno,
e->col_offset + 1,
e->end_lineno,
e->end_col_offset + 1);
VISIT_QUIT(st, 0);
}
if (e->v.Lambda.args->defaults)
VISIT_SEQ(st, expr, e->v.Lambda.args->defaults);
if (e->v.Lambda.args->kw_defaults)