Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da20cd2

Browse files
committed
fix refcnt/style/debuging oversights
1 parent 94c001b commit da20cd2

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Python/errors.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,15 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
593593
if (msg == NULL)
594594
return NULL;
595595

596-
args = PyTuple_New(1);
596+
args = PyTuple_New(0);
597597
if (args == NULL)
598598
return NULL;
599599

600600
kwargs = PyDict_New();
601-
if (kwargs == NULL)
601+
if (kwargs == NULL) {
602+
Py_DECREF(args);
602603
return NULL;
604+
}
603605

604606
if (name == NULL) {
605607
Py_INCREF(Py_None);
@@ -612,13 +614,13 @@ PyErr_SetImportError(PyObject *msg, PyObject *name, PyObject *path)
612614
}
613615

614616
Py_INCREF(msg);
615-
PyTuple_SetItem(args, 0, NULL);//msg);
617+
PyTuple_SET_ITEM(args, 0, msg);
616618
PyDict_SetItemString(kwargs, "name", name);
617619
PyDict_SetItemString(kwargs, "path", path);
618620

619621
error = PyObject_Call(PyExc_ImportError, args, kwargs);
620-
if (error!= NULL) {
621-
PyErr_SetObject((PyObject *) Py_TYPE(error), error);
622+
if (error != NULL) {
623+
PyErr_SetObject((PyObject *)Py_TYPE(error), error);
622624
Py_DECREF(error);
623625
}
624626

0 commit comments

Comments
 (0)