diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-15 19:10:39 +1000 |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-15 19:10:39 +1000 |
commit | 142944102f6bd2b4cdcf8e80035167c181422502 (patch) | |
tree | 5a8b144e98ebd8dd9957e94b8d7efdbc31474cd6 /Python/pythonrun.c | |
parent | 2db6c132e0440848d9b6d29d9146df7349029d36 (diff) | |
download | cpython-142944102f6bd2b4cdcf8e80035167c181422502.tar.gz |
Actually initialize __main__.__loader__ with loader instances, not the corresponding type objects
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 970834e0bb..8130cc5289 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1355,11 +1355,15 @@ set_main_loader(PyObject *d, const char *filename, const char *loader_name) { PyInterpreterState *interp; PyThreadState *tstate; - PyObject *loader; + PyObject *loader_type, *loader; /* Get current thread state and interpreter pointer */ tstate = PyThreadState_GET(); interp = tstate->interp; - loader = PyObject_GetAttrString(interp->importlib, loader_name); + loader_type = PyObject_GetAttrString(interp->importlib, loader_name); + if (loader_type == NULL) { + return -1; + } + loader = PyObject_CallFunction(loader_type, "ss", "__main__", filename); if (loader == NULL || (PyDict_SetItemString(d, "__loader__", loader) < 0)) { return -1; |