Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "not correct"
This reverts commit 5ade8d4.
  • Loading branch information
JelleZijlstra committed Apr 26, 2024
commit ba90c9764ba62b288ef0b262ff3b57ecb9e16161
5 changes: 1 addition & 4 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,6 @@ static PyCodeObject *optimize_and_assemble(struct compiler *, int addNone);

#define CAPSULE_NAME "compile.c compiler unit"

static inline bool in_class_like_block(struct compiler *c) {
return c->u->u_ste->ste_type == ClassBlock || c->u->u_ste->ste_can_see_class_scope;
}

static int
compiler_setup(struct compiler *c, mod_ty mod, PyObject *filename,
Expand Down Expand Up @@ -5463,7 +5460,7 @@ push_inlined_comprehension_state(struct compiler *c, location loc,
PySTEntryObject *entry,
inlined_comprehension_state *state)
{
int in_class_block = in_class_like_block(c) && !c->u->u_in_inlined_comp;
int in_class_block = (c->u->u_ste->ste_type == ClassBlock) && !c->u->u_in_inlined_comp;
c->u->u_in_inlined_comp++;
// iterate over names bound in the comprehension and ensure we isolate
// them from the outer scope as needed
Expand Down
3 changes: 1 addition & 2 deletions Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,7 @@ inline_comprehension(PySTEntryObject *ste, PySTEntryObject *comp,
// free vars in comprehension that are locals in outer scope can
// now simply be locals, unless they are free in comp children,
// or if the outer scope is a class block
if (!is_free_in_any_child(comp, k) && ste->ste_type != ClassBlock
&& !ste->ste_can_see_class_scope) {
if (!is_free_in_any_child(comp, k) && ste->ste_type != ClassBlock) {
if (PySet_Discard(comp_free, k) < 0) {
return 0;
}
Expand Down