diff options
author | Brian Curtin <brian@python.org> | 2012-04-18 13:30:51 (GMT) |
---|---|---|
committer | Brian Curtin <brian@python.org> | 2012-04-18 13:30:51 (GMT) |
commit | 94c001b50377267626e136949ba410c8ad28a6f0 (patch) | |
tree | a7d1b531fdb547915b9df4cadbe71a7a70115cae /Python/errors.c | |
parent | 03c7ed15803def1eedec65522e6185fc5a1badf9 (diff) | |
download | cpython-94c001b50377267626e136949ba410c8ad28a6f0.zip cpython-94c001b50377267626e136949ba410c8ad28a6f0.tar.gz cpython-94c001b50377267626e136949ba410c8ad28a6f0.tar.bz2 |
Fix email post-commit review comments.
Add INCREFs, fix args->kwargs, and a second args==NULL check was removed,
left over from a merger with another function. Instead, checking msg==NULL
does what that used to do in a roundabout way.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Python/errors.c b/Python/errors.c index a49cde6..63eebe2 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -590,29 +590,32 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path) { PyObject *args, *kwargs, *error; + if (msg == NULL) + return NULL; + args = PyTuple_New(1); if (args == NULL) return NULL; kwargs = PyDict_New(); - if (args == NULL) + if (kwargs == NULL) return NULL; - if (name == NULL) + if (name == NULL) { + Py_INCREF(Py_None); name = Py_None; + } - if (path == NULL) + if (path == NULL) { + Py_INCREF(Py_None); path = Py_None; + } Py_INCREF(msg); - PyTuple_SetItem(args, 0, msg); + PyTuple_SetItem(args, 0, NULL);//msg); PyDict_SetItemString(kwargs, "name", name); PyDict_SetItemString(kwargs, "path", path); - /* args must at least be an empty tuple */ - if (args == NULL) - args = PyTuple_New(0); - error = PyObject_Call(PyExc_ImportError, args, kwargs); if (error!= NULL) { PyErr_SetObject((PyObject *) Py_TYPE(error), error); |