mirror of
https://github.com/python/cpython.git
synced 2025-07-21 18:25:22 +00:00
Issue #27809: PyErr_SetImportError() uses fast call
This commit is contained in:
parent
3a84097291
commit
f45a56150b
1 changed files with 8 additions and 14 deletions
|
@ -699,18 +699,14 @@ PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename(
|
||||||
PyObject *
|
PyObject *
|
||||||
PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
|
PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
|
||||||
{
|
{
|
||||||
PyObject *args, *kwargs, *error;
|
PyObject *kwargs, *error;
|
||||||
|
|
||||||
if (msg == NULL)
|
if (msg == NULL) {
|
||||||
return NULL;
|
|
||||||
|
|
||||||
args = PyTuple_New(1);
|
|
||||||
if (args == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
kwargs = PyDict_New();
|
kwargs = PyDict_New();
|
||||||
if (kwargs == NULL) {
|
if (kwargs == NULL) {
|
||||||
Py_DECREF(args);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,22 +718,20 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
|
||||||
path = Py_None;
|
path = Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(msg);
|
if (PyDict_SetItemString(kwargs, "name", name) < 0) {
|
||||||
PyTuple_SET_ITEM(args, 0, msg);
|
|
||||||
|
|
||||||
if (PyDict_SetItemString(kwargs, "name", name) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
if (PyDict_SetItemString(kwargs, "path", path) < 0)
|
}
|
||||||
|
if (PyDict_SetItemString(kwargs, "path", path) < 0) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
error = PyObject_Call(PyExc_ImportError, args, kwargs);
|
error = _PyObject_FastCallDict(PyExc_ImportError, &msg, 1, kwargs);
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
PyErr_SetObject((PyObject *)Py_TYPE(error), error);
|
PyErr_SetObject((PyObject *)Py_TYPE(error), error);
|
||||||
Py_DECREF(error);
|
Py_DECREF(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
Py_DECREF(args);
|
|
||||||
Py_DECREF(kwargs);
|
Py_DECREF(kwargs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue