diff options
Diffstat (limited to 'Python/generated_cases.c.h')
| -rw-r--r-- | Python/generated_cases.c.h | 42 | 
1 files changed, 42 insertions, 0 deletions
| diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 36c7498a69..bea51d7e51 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1011,6 +1011,48 @@              goto exception_unwind;          } +        TARGET(STOPITERATION_ERROR) { +            assert(frame->owner == FRAME_OWNED_BY_GENERATOR); +            PyObject *exc = TOP(); +            assert(PyExceptionInstance_Check(exc)); +            const char *msg = NULL; +            if (PyErr_GivenExceptionMatches(exc, PyExc_StopIteration)) { +                msg = "generator raised StopIteration"; +                if (frame->f_code->co_flags & CO_ASYNC_GENERATOR) { +                    msg = "async generator raised StopIteration"; +                } +                else if (frame->f_code->co_flags & CO_COROUTINE) { +                    msg = "coroutine raised StopIteration"; +                } +            } +            else if ((frame->f_code->co_flags & CO_ASYNC_GENERATOR) && +                    PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) +            { +                /* code in `gen` raised a StopAsyncIteration error: +                raise a RuntimeError. +                */ +                msg = "async generator raised StopAsyncIteration"; +            } +            if (msg != NULL) { +                PyObject *message = _PyUnicode_FromASCII(msg, strlen(msg)); +                if (message == NULL) { +                    goto error; +                } +                PyObject *error = PyObject_CallOneArg(PyExc_RuntimeError, message); +                if (error == NULL) { +                    Py_DECREF(message); +                    goto error; +                } +                assert(PyExceptionInstance_Check(error)); +                SET_TOP(error); +                PyException_SetCause(error, exc); +                Py_INCREF(exc); +                PyException_SetContext(error, exc); +                Py_DECREF(message); +            } +            DISPATCH(); +        } +          TARGET(LOAD_ASSERTION_ERROR) {              PyObject *value = PyExc_AssertionError;              Py_INCREF(value); | 
