diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-06 17:15:23 +0200 |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-05-06 17:15:23 +0200 |
| commit | 03507f25cc48d46466ff1923b9a5d5308d54812c (patch) | |
| tree | 6dda57ee450c956b26be63c3f7ae3023b1787f56 /Python/import.c | |
| parent | 959a9707ae8c58b3d3148caa3bbd0a3d6582d179 (diff) | |
| download | cpython-03507f25cc48d46466ff1923b9a5d5308d54812c.tar.gz | |
Fix too early decrefs.
Diffstat (limited to 'Python/import.c')
| -rw-r--r-- | Python/import.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index ccba1066d2..fd42a892a1 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1639,7 +1639,6 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, if (level == 0) { final_mod = PyDict_GetItem(interp->modules, front); - Py_DECREF(front); if (final_mod == NULL) { PyErr_Format(PyExc_KeyError, "%R not in sys.modules as expected", front); @@ -1647,6 +1646,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, else { Py_INCREF(final_mod); } + Py_DECREF(front); } else { Py_ssize_t cut_off = PyUnicode_GET_LENGTH(name) - @@ -1660,7 +1660,6 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, } final_mod = PyDict_GetItem(interp->modules, to_return); - Py_DECREF(to_return); if (final_mod == NULL) { PyErr_Format(PyExc_KeyError, "%R not in sys.modules as expected", @@ -1669,6 +1668,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, else { Py_INCREF(final_mod); } + Py_DECREF(to_return); } } else { |
