diff options
author | Mark Shannon <mark@hotpy.org> | 2023-01-05 16:05:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-05 16:05:51 (GMT) |
commit | 28187141cc34063ef857976ddbca87ba09a882c2 (patch) | |
tree | 852d652bd98f0f7e322a30f6d648a1a4ce9612b2 /Python/generated_cases.c.h | |
parent | f20c553a458659f247fac1fb829f8172aa32f69a (diff) | |
download | cpython-28187141cc34063ef857976ddbca87ba09a882c2.zip cpython-28187141cc34063ef857976ddbca87ba09a882c2.tar.gz cpython-28187141cc34063ef857976ddbca87ba09a882c2.tar.bz2 |
GH-99005: Add `CALL_INTRINSIC_1` instruction (GH-100771)
* Remove PRINT_EXPR instruction
* Remove STOPITERATION_ERROR instruction
* Remove IMPORT_STAR instruction
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r-- | Python/generated_cases.c.h | 82 |
1 files changed, 4 insertions, 78 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index fa1f941..0d4dad4 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -684,22 +684,14 @@ DISPATCH(); } - TARGET(PRINT_EXPR) { + TARGET(CALL_INTRINSIC_1) { PyObject *value = PEEK(1); - PyObject *hook = _PySys_GetAttr(tstate, &_Py_ID(displayhook)); PyObject *res; - // Can't use ERROR_IF here. - if (hook == NULL) { - _PyErr_SetString(tstate, PyExc_RuntimeError, - "lost sys.displayhook"); - Py_DECREF(value); - if (true) goto pop_1_error; - } - res = PyObject_CallOneArg(hook, value); + assert(oparg <= MAX_INTRINSIC_1); + res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value); Py_DECREF(value); if (res == NULL) goto pop_1_error; - Py_DECREF(res); - STACK_SHRINK(1); + POKE(1, res); DISPATCH(); } @@ -1045,48 +1037,6 @@ DISPATCH(); } - 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, Py_NewRef(exc)); - // Steal exc reference, rather than Py_NewRef+Py_DECREF - PyException_SetContext(error, exc); - Py_DECREF(message); - } - DISPATCH(); - } - TARGET(LOAD_ASSERTION_ERROR) { PyObject *value; value = Py_NewRef(PyExc_AssertionError); @@ -2401,30 +2351,6 @@ DISPATCH(); } - TARGET(IMPORT_STAR) { - PyObject *from = PEEK(1); - PyObject *locals; - int err; - if (_PyFrame_FastToLocalsWithError(frame) < 0) { - Py_DECREF(from); - if (true) goto pop_1_error; - } - - locals = LOCALS(); - if (locals == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no locals found during 'import *'"); - Py_DECREF(from); - if (true) goto pop_1_error; - } - err = import_all_from(tstate, locals, from); - _PyFrame_LocalsToFast(frame, 0); - Py_DECREF(from); - if (err) goto pop_1_error; - STACK_SHRINK(1); - DISPATCH(); - } - TARGET(IMPORT_FROM) { PyObject *from = PEEK(1); PyObject *res; |