|
82 | 82 | static PyObject *value, *value1, *value2, *left, *right, *res, *sum, *prod, *sub;
|
83 | 83 | static PyObject *container, *start, *stop, *v, *lhs, *rhs;
|
84 | 84 | static PyObject *list, *tuple, *dict, *owner;
|
85 |
| -static PyObject *exit_func, *lasti, *val, *retval; |
| 85 | +static PyObject *exit_func, *lasti, *val, *retval, *obj, *iter; |
86 | 86 | static size_t jump;
|
87 | 87 | // Dummy variables for cache effects
|
88 | 88 | static _Py_CODEUNIT when_to_jump_mask, invert, counter, index, hint;
|
@@ -611,48 +611,37 @@ dummy_func(
|
611 | 611 | goto resume_frame;
|
612 | 612 | }
|
613 | 613 |
|
614 |
| - // stack effect: ( -- ) |
615 |
| - inst(GET_AITER) { |
| 614 | + inst(GET_AITER, (obj -- iter)) { |
616 | 615 | unaryfunc getter = NULL;
|
617 |
| - PyObject *iter = NULL; |
618 |
| - PyObject *obj = TOP(); |
619 | 616 | PyTypeObject *type = Py_TYPE(obj);
|
620 | 617 |
|
621 | 618 | if (type->tp_as_async != NULL) {
|
622 | 619 | getter = type->tp_as_async->am_aiter;
|
623 | 620 | }
|
624 | 621 |
|
625 |
| - if (getter != NULL) { |
626 |
| - iter = (*getter)(obj); |
627 |
| - Py_DECREF(obj); |
628 |
| - if (iter == NULL) { |
629 |
| - SET_TOP(NULL); |
630 |
| - goto error; |
631 |
| - } |
632 |
| - } |
633 |
| - else { |
634 |
| - SET_TOP(NULL); |
| 622 | + if (getter == NULL) { |
635 | 623 | _PyErr_Format(tstate, PyExc_TypeError,
|
636 | 624 | "'async for' requires an object with "
|
637 | 625 | "__aiter__ method, got %.100s",
|
638 | 626 | type->tp_name);
|
639 | 627 | Py_DECREF(obj);
|
640 |
| - goto error; |
| 628 | + ERROR_IF(1, error); |
641 | 629 | }
|
642 | 630 |
|
| 631 | + iter = (*getter)(obj); |
| 632 | + Py_DECREF(obj); |
| 633 | + ERROR_IF(iter == NULL, error); |
| 634 | + |
643 | 635 | if (Py_TYPE(iter)->tp_as_async == NULL ||
|
644 | 636 | Py_TYPE(iter)->tp_as_async->am_anext == NULL) {
|
645 | 637 |
|
646 |
| - SET_TOP(NULL); |
647 | 638 | _PyErr_Format(tstate, PyExc_TypeError,
|
648 | 639 | "'async for' received an object from __aiter__ "
|
649 | 640 | "that does not implement __anext__: %.100s",
|
650 | 641 | Py_TYPE(iter)->tp_name);
|
651 | 642 | Py_DECREF(iter);
|
652 |
| - goto error; |
| 643 | + ERROR_IF(1, error); |
653 | 644 | }
|
654 |
| - |
655 |
| - SET_TOP(iter); |
656 | 645 | }
|
657 | 646 |
|
658 | 647 | // stack effect: ( -- __0)
|
|
0 commit comments