-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
[3.14] GH-135171: Revert async generator expressions behavior #135352
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.14
Are you sure you want to change the base?
Changes from 1 commit
d04629b
53bd362
75e6184
549cd11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Reverts the behavior of async generator expressions when created with object | ||
w/o __aiter__ method to the pre-3.13 behavior of raising a TypeError. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4544,9 +4544,9 @@ codegen_async_comprehension_generator(compiler *c, location loc, | |
else { | ||
/* Sub-iter - calculate on the fly */ | ||
VISIT(c, expr, gen->iter); | ||
ADDOP(c, LOC(gen->iter), GET_AITER); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, is this change necessary? I think the test passes without it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. There was a bug in previous commit. I've reverted related logic in |
||
} | ||
} | ||
ADDOP(c, LOC(gen->iter), GET_AITER); | ||
|
||
USE_LABEL(c, start); | ||
/* Runtime will push a block here, so we need to account for that */ | ||
|
@@ -4776,7 +4776,6 @@ codegen_comprehension(compiler *c, expr_ty e, int type, | |
location loc = LOC(e); | ||
|
||
outermost = (comprehension_ty) asdl_seq_GET(generators, 0); | ||
int is_sync_genexpr = type == COMP_GENEXP && !outermost->is_async; | ||
if (is_inlined) { | ||
VISIT(c, expr, outermost->iter); | ||
if (push_inlined_comprehension_state(c, loc, entry, &inline_state)) { | ||
|
@@ -4853,8 +4852,13 @@ codegen_comprehension(compiler *c, expr_ty e, int type, | |
Py_CLEAR(co); | ||
|
||
VISIT(c, expr, outermost->iter); | ||
if (is_sync_genexpr) { | ||
ADDOP(c, loc, GET_ITER); | ||
if (type == COMP_GENEXP) { | ||
if (outermost->is_async) { | ||
ADDOP(c, loc, GET_AITER); | ||
} | ||
else { | ||
ADDOP(c, loc, GET_ITER); | ||
} | ||
} | ||
ADDOP_I(c, loc, CALL, 0); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.