|
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;
|
@@ -616,48 +616,37 @@ dummy_func(
|
616 | 616 | goto resume_frame;
|
617 | 617 | }
|
618 | 618 |
|
619 |
| - // stack effect: ( -- ) |
620 |
| - inst(GET_AITER) { |
| 619 | + inst(GET_AITER, (obj -- iter)) { |
621 | 620 | unaryfunc getter = NULL;
|
622 |
| - PyObject *iter = NULL; |
623 |
| - PyObject *obj = TOP(); |
624 | 621 | PyTypeObject *type = Py_TYPE(obj);
|
625 | 622 |
|
626 | 623 | if (type->tp_as_async != NULL) {
|
627 | 624 | getter = type->tp_as_async->am_aiter;
|
628 | 625 | }
|
629 | 626 |
|
630 |
| - if (getter != NULL) { |
631 |
| - iter = (*getter)(obj); |
632 |
| - Py_DECREF(obj); |
633 |
| - if (iter == NULL) { |
634 |
| - SET_TOP(NULL); |
635 |
| - goto error; |
636 |
| - } |
637 |
| - } |
638 |
| - else { |
639 |
| - SET_TOP(NULL); |
| 627 | + if (getter == NULL) { |
640 | 628 | _PyErr_Format(tstate, PyExc_TypeError,
|
641 | 629 | "'async for' requires an object with "
|
642 | 630 | "__aiter__ method, got %.100s",
|
643 | 631 | type->tp_name);
|
644 | 632 | Py_DECREF(obj);
|
645 |
| - goto error; |
| 633 | + ERROR_IF(1, error); |
646 | 634 | }
|
647 | 635 |
|
| 636 | + iter = (*getter)(obj); |
| 637 | + Py_DECREF(obj); |
| 638 | + ERROR_IF(iter == NULL, error); |
| 639 | + |
648 | 640 | if (Py_TYPE(iter)->tp_as_async == NULL ||
|
649 | 641 | Py_TYPE(iter)->tp_as_async->am_anext == NULL) {
|
650 | 642 |
|
651 |
| - SET_TOP(NULL); |
652 | 643 | _PyErr_Format(tstate, PyExc_TypeError,
|
653 | 644 | "'async for' received an object from __aiter__ "
|
654 | 645 | "that does not implement __anext__: %.100s",
|
655 | 646 | Py_TYPE(iter)->tp_name);
|
656 | 647 | Py_DECREF(iter);
|
657 |
| - goto error; |
| 648 | + ERROR_IF(1, error); |
658 | 649 | }
|
659 |
| - |
660 |
| - SET_TOP(iter); |
661 | 650 | }
|
662 | 651 |
|
663 | 652 | // stack effect: ( -- __0)
|
|
0 commit comments