Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-109118: Make comprehensions work within annotation scopes, but without inlining#118160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 7 commits intopython:mainfromJelleZijlstra:lambdaanno
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from1 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
PrevPrevious commit
NextNext commit
not correct
  • Loading branch information
@JelleZijlstra
JelleZijlstra committedApr 22, 2024
commit5ade8d4836a23567eddff7251ae385c502f7d981
5 changes: 4 additions & 1 deletionPython/compile.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -371,6 +371,9 @@ 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 DownExpand Up@@ -5460,7 +5463,7 @@ push_inlined_comprehension_state(struct compiler *c, location loc,
PySTEntryObject *entry,
inlined_comprehension_state *state)
{
int in_class_block =(c->u->u_ste->ste_type == ClassBlock) && !c->u->u_in_inlined_comp;
int in_class_block =in_class_like_block(c) && !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: 2 additions & 1 deletionPython/symtable.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -810,7 +810,8 @@ 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) {
if (!is_free_in_any_child(comp, k) && ste->ste_type != ClassBlock
&& !ste->ste_can_see_class_scope) {
if (PySet_Discard(comp_free, k) < 0) {
return 0;
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp