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

Commit0181aa2

Browse files
authored
[3.12]gh-123142: fix too wide source location of GET_ITER/GET_AITER (GH-123420). (#123436)
(cherry picked from commit61bef62)
1 parentccc6c2b commit0181aa2

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed

‎Lib/test/support/__init__.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2472,14 +2472,17 @@ def is_slot_wrapper(name, value):
24722472

24732473

24742474
classBrokenIter:
2475-
def__init__(self,init_raises=False,next_raises=False):
2475+
def__init__(self,init_raises=False,next_raises=False,iter_raises=False):
24762476
ifinit_raises:
24772477
1/0
24782478
self.next_raises=next_raises
2479+
self.iter_raises=iter_raises
24792480

24802481
def__next__(self):
24812482
ifself.next_raises:
24822483
1/0
24832484

24842485
def__iter__(self):
2486+
ifself.iter_raises:
2487+
1/0
24852488
returnself

‎Lib/test/test_dictcomps.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,15 @@ def next_raises():
145145
exceptExceptionase:
146146
returne
147147

148+
defiter_raises():
149+
try:
150+
{x:xforxinBrokenIter(iter_raises=True)}
151+
exceptExceptionase:
152+
returne
153+
148154
forfunc,expectedin [(init_raises,"BrokenIter(init_raises=True)"),
149155
(next_raises,"BrokenIter(next_raises=True)"),
156+
(iter_raises,"BrokenIter(iter_raises=True)"),
150157
]:
151158
withself.subTest(func):
152159
exc=func()

‎Lib/test/test_iter.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,8 +1163,16 @@ def next_raises():
11631163
exceptExceptionase:
11641164
returne
11651165

1166+
defiter_raises():
1167+
try:
1168+
forxinBrokenIter(iter_raises=True):
1169+
pass
1170+
exceptExceptionase:
1171+
returne
1172+
11661173
forfunc,expectedin [(init_raises,"BrokenIter(init_raises=True)"),
11671174
(next_raises,"BrokenIter(next_raises=True)"),
1175+
(iter_raises,"BrokenIter(iter_raises=True)"),
11681176
]:
11691177
withself.subTest(func):
11701178
exc=func()

‎Lib/test/test_listcomps.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,15 @@ def next_raises():
725725
exceptExceptionase:
726726
returne
727727

728+
defiter_raises():
729+
try:
730+
[xforxinBrokenIter(iter_raises=True)]
731+
exceptExceptionase:
732+
returne
733+
728734
forfunc,expectedin [(init_raises,"BrokenIter(init_raises=True)"),
729735
(next_raises,"BrokenIter(next_raises=True)"),
736+
(iter_raises,"BrokenIter(iter_raises=True)"),
730737
]:
731738
withself.subTest(func):
732739
exc=func()

‎Lib/test/test_setcomps.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,15 @@ def next_raises():
168168
exceptExceptionase:
169169
returne
170170

171+
defiter_raises():
172+
try:
173+
{xforxinBrokenIter(iter_raises=True)}
174+
exceptExceptionase:
175+
returne
176+
171177
forfunc,expectedin [(init_raises,"BrokenIter(init_raises=True)"),
172178
(next_raises,"BrokenIter(next_raises=True)"),
179+
(iter_raises,"BrokenIter(iter_raises=True)"),
173180
]:
174181
withself.subTest(func):
175182
exc=func()

‎Python/compile.c‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ compiler_async_for(struct compiler *c, stmt_ty s)
30693069
NEW_JUMP_TARGET_LABEL(c,end);
30703070

30713071
VISIT(c,expr,s->v.AsyncFor.iter);
3072-
ADDOP(c,loc,GET_AITER);
3072+
ADDOP(c,LOC(s->v.AsyncFor.iter),GET_AITER);
30733073

30743074
USE_LABEL(c,start);
30753075
RETURN_IF_ERROR(compiler_push_fblock(c,loc,FOR_LOOP,start,end,NULL));
@@ -5367,7 +5367,7 @@ compiler_async_comprehension_generator(struct compiler *c, location loc,
53675367
else {
53685368
/* Sub-iter - calculate on the fly */
53695369
VISIT(c,expr,gen->iter);
5370-
ADDOP(c,loc,GET_AITER);
5370+
ADDOP(c,LOC(gen->iter),GET_AITER);
53715371
}
53725372
}
53735373

@@ -5652,15 +5652,14 @@ pop_inlined_comprehension_state(struct compiler *c, location loc,
56525652
}
56535653

56545654
staticinlineint
5655-
compiler_comprehension_iter(structcompiler*c,locationloc,
5656-
comprehension_tycomp)
5655+
compiler_comprehension_iter(structcompiler*c,comprehension_tycomp)
56575656
{
56585657
VISIT(c,expr,comp->iter);
56595658
if (comp->is_async) {
5660-
ADDOP(c,loc,GET_AITER);
5659+
ADDOP(c,LOC(comp->iter),GET_AITER);
56615660
}
56625661
else {
5663-
ADDOP(c,loc,GET_ITER);
5662+
ADDOP(c,LOC(comp->iter),GET_ITER);
56645663
}
56655664
returnSUCCESS;
56665665
}
@@ -5686,7 +5685,7 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
56865685

56875686
outermost= (comprehension_ty)asdl_seq_GET(generators,0);
56885687
if (is_inlined) {
5689-
if (compiler_comprehension_iter(c,loc,outermost)) {
5688+
if (compiler_comprehension_iter(c,outermost)) {
56905689
gotoerror;
56915690
}
56925691
if (push_inlined_comprehension_state(c,loc,entry,&inline_state)) {
@@ -5772,7 +5771,7 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
57725771
}
57735772
Py_CLEAR(co);
57745773

5775-
if (compiler_comprehension_iter(c,loc,outermost)) {
5774+
if (compiler_comprehension_iter(c,outermost)) {
57765775
gotoerror;
57775776
}
57785777

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp