Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 78117:27e13497d545
Refcounting fixes
| author | Nick Coghlan <ncoghlan@gmail.com> |
|---|---|
| date | Sun, 15 Jul 2012 23:21:08 +1000 |
| parents | 8bf691d0b004 |
| children | 2f1494d243ad |
line wrap: on
line diff
--- a/Python/pythonrun.c Sun Jul 15 23:18:08 2012 +1000 +++ b/Python/pythonrun.c Sun Jul 15 23:21:08 2012 +1000 @@ -1356,6 +1356,7 @@ PyInterpreterState *interp; PyThreadState *tstate; PyObject *loader_type, *loader; + int result = 0; /* Get current thread state and interpreter pointer */ tstate = PyThreadState_GET(); interp = tstate->interp; @@ -1364,12 +1365,15 @@ return -1; } loader = PyObject_CallFunction(loader_type, "ss", "__main__", filename); - if (loader == NULL || - (PyDict_SetItemString(d, "__loader__", loader) < 0)) { + Py_DECREF(loader_type); + if (loader == NULL) { return -1; } + if (PyDict_SetItemString(d, "__loader__", loader) < 0) { + result = -1; + } Py_DECREF(loader); - return 0; + return result; } int
