mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-118702: Implement vectorcall for BaseException (#118703)
* BaseException_vectorcall() now creates a tuple from 'args' array. * Creation an exception using BaseException_vectorcall() is now a single function call, rather than having to call BaseException_new() and then BaseException_init(). Calling BaseException_init() is inefficient since it overrides the 'args' attribute. * _PyErr_SetKeyError() now uses PyObject_CallOneArg() to create the KeyError instance to use BaseException_vectorcall().
This commit is contained in:
parent
ec9d12be96
commit
aa36f83c16
3 changed files with 68 additions and 4 deletions
|
@ -257,13 +257,14 @@ void
|
|||
_PyErr_SetKeyError(PyObject *arg)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
PyObject *tup = PyTuple_Pack(1, arg);
|
||||
if (!tup) {
|
||||
PyObject *exc = PyObject_CallOneArg(PyExc_KeyError, arg);
|
||||
if (!exc) {
|
||||
/* caller will expect error to be set anyway */
|
||||
return;
|
||||
}
|
||||
_PyErr_SetObject(tstate, PyExc_KeyError, tup);
|
||||
Py_DECREF(tup);
|
||||
|
||||
_PyErr_SetObject(tstate, (PyObject*)Py_TYPE(exc), exc);
|
||||
Py_DECREF(exc);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue