summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-23 00:04:41 +0200
committerVictor Stinner <victor.stinner@gmail.com>2016-08-23 00:04:41 +0200
commitb35603f9f15c1060eb903181324a26ce20336cc4 (patch)
tree2d42f86851e031ad08283f4b8f464cb604dbed54 /Python/errors.c
parent9023e576b75ac630835d9140f2a2b60ec2e00c04 (diff)
downloadcpython-b35603f9f15c1060eb903181324a26ce20336cc4.tar.gz
Issue #27809: PyErr_SetImportError() uses fast call
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 956e4fa583..e6285e8b3b 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -699,18 +699,14 @@ PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename(
PyObject *
PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
{
- PyObject *args, *kwargs, *error;
+ PyObject *kwargs, *error;
- if (msg == NULL)
- return NULL;
-
- args = PyTuple_New(1);
- if (args == NULL)
+ if (msg == NULL) {
return NULL;
+ }
kwargs = PyDict_New();
if (kwargs == NULL) {
- Py_DECREF(args);
return NULL;
}
@@ -722,22 +718,20 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
path = Py_None;
}
- Py_INCREF(msg);
- PyTuple_SET_ITEM(args, 0, msg);
-
- if (PyDict_SetItemString(kwargs, "name", name) < 0)
+ if (PyDict_SetItemString(kwargs, "name", name) < 0) {
goto done;
- if (PyDict_SetItemString(kwargs, "path", path) < 0)
+ }
+ if (PyDict_SetItemString(kwargs, "path", path) < 0) {
goto done;
+ }
- error = PyObject_Call(PyExc_ImportError, args, kwargs);
+ error = _PyObject_FastCallDict(PyExc_ImportError, &msg, 1, kwargs);
if (error != NULL) {
PyErr_SetObject((PyObject *)Py_TYPE(error), error);
Py_DECREF(error);
}
done:
- Py_DECREF(args);
Py_DECREF(kwargs);
return NULL;
}