bpo-33041: Add missed error checks when compile "async for" (#6053) · python/cpython@67ee077 (original) (raw)
`@@ -2437,7 +2437,7 @@ compiler_async_for(struct compiler *c, stmt_ty s)
`
2437
2437
`_Py_IDENTIFIER(StopAsyncIteration);
`
2438
2438
``
2439
2439
`basicblock *try, *except, *end, *after_try, *try_cleanup,
`
2440
``
`-
*after_loop, *after_loop_else;
`
``
2440
`+
*after_loop_else;
`
2441
2441
``
2442
2442
`PyObject *stop_aiter_error = _PyUnicode_FromId(&PyId_StopAsyncIteration);
`
2443
2443
`if (stop_aiter_error == NULL) {
`
`@@ -2449,14 +2449,14 @@ compiler_async_for(struct compiler *c, stmt_ty s)
`
2449
2449
`end = compiler_new_block(c);
`
2450
2450
`after_try = compiler_new_block(c);
`
2451
2451
`try_cleanup = compiler_new_block(c);
`
2452
``
`-
after_loop = compiler_new_block(c);
`
2453
2452
`after_loop_else = compiler_new_block(c);
`
2454
2453
``
2455
2454
`if (try == NULL || except == NULL || end == NULL
`
2456
``
`-
|| after_try == NULL || try_cleanup == NULL)
`
``
2455
`+
|| after_try == NULL || try_cleanup == NULL
`
``
2456
`+
|| after_loop_else == NULL)
`
2457
2457
`return 0;
`
2458
2458
``
2459
``
`-
if (!compiler_push_fblock(c, FOR_LOOP, try, after_loop))
`
``
2459
`+
if (!compiler_push_fblock(c, FOR_LOOP, try, end))
`
2460
2460
`return 0;
`
2461
2461
``
2462
2462
`VISIT(c, expr, s->v.AsyncFor.iter);
`
`@@ -2504,10 +2504,6 @@ compiler_async_for(struct compiler *c, stmt_ty s)
`
2504
2504
``
2505
2505
`compiler_pop_fblock(c, FOR_LOOP, try);
`
2506
2506
``
2507
``
`` -
/* Block reached after break
ing from loop */
``
2508
``
`-
compiler_use_next_block(c, after_loop);
`
2509
``
`-
ADDOP_JABS(c, JUMP_ABSOLUTE, end);
`
2510
``
-
2511
2507
`` /* else
block */
``
2512
2508
`compiler_use_next_block(c, after_loop_else);
`
2513
2509
`VISIT_SEQ(c, stmt, s->v.For.orelse);
`
`@@ -4014,7 +4010,7 @@ compiler_async_comprehension_generator(struct compiler *c,
`
4014
4010
`_Py_IDENTIFIER(StopAsyncIteration);
`
4015
4011
``
4016
4012
`comprehension_ty gen;
`
4017
``
`-
basicblock *anchor, *skip, *if_cleanup, *try,
`
``
4013
`+
basicblock *anchor, *if_cleanup, *try,
`
4018
4014
`*after_try, *except, *try_cleanup;
`
4019
4015
`Py_ssize_t i, n;
`
4020
4016
``
`@@ -4027,13 +4023,12 @@ compiler_async_comprehension_generator(struct compiler *c,
`
4027
4023
`after_try = compiler_new_block(c);
`
4028
4024
`try_cleanup = compiler_new_block(c);
`
4029
4025
`except = compiler_new_block(c);
`
4030
``
`-
skip = compiler_new_block(c);
`
4031
4026
`if_cleanup = compiler_new_block(c);
`
4032
4027
`anchor = compiler_new_block(c);
`
4033
4028
``
4034
``
`-
if (skip == NULL || if_cleanup == NULL || anchor == NULL ||
`
``
4029
`+
if (if_cleanup == NULL || anchor == NULL ||
`
4035
4030
`try == NULL || after_try == NULL ||
`
4036
``
`-
except == NULL || after_try == NULL) {
`
``
4031
`+
except == NULL || try_cleanup == NULL) {
`
4037
4032
`return 0;
`
4038
4033
` }
`
4039
4034
``
`@@ -4125,8 +4120,6 @@ compiler_async_comprehension_generator(struct compiler *c,
`
4125
4120
`default:
`
4126
4121
`return 0;
`
4127
4122
` }
`
4128
``
-
4129
``
`-
compiler_use_next_block(c, skip);
`
4130
4123
` }
`
4131
4124
`compiler_use_next_block(c, if_cleanup);
`
4132
4125
`ADDOP_JABS(c, JUMP_ABSOLUTE, try);
`