diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2023-05-18 05:22:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-18 05:22:17 (GMT) |
commit | 662aede68b0ea222cf3db4715b310e91c51b665f (patch) | |
tree | 3b560e61fa420eb18de21cfc68a6c196a156a214 /Python/symtable.c | |
parent | 152227b569c3a9b87fe0483706f704762ced6d75 (diff) | |
download | cpython-662aede68b0ea222cf3db4715b310e91c51b665f.zip cpython-662aede68b0ea222cf3db4715b310e91c51b665f.tar.gz cpython-662aede68b0ea222cf3db4715b310e91c51b665f.tar.bz2 |
gh-104374: Remove access to class scopes for inlined comprehensions (#104528)
Co-authored-by: Carl Meyer <carl@oddbird.net>
Diffstat (limited to 'Python/symtable.c')
-rw-r--r-- | Python/symtable.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/symtable.c b/Python/symtable.c index f896f7c..a319c23 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -674,8 +674,9 @@ 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 - if (!is_free_in_any_child(comp, k)) { + // 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) { if (PySet_Discard(comp_free, k) < 0) { return 0; } |