summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-07-15 09:10:39 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-07-15 09:10:39 (GMT)
commit3f94cbf9eba7adef027cfc5d087b3660800df9d7 (patch)
tree832bb91df8040ab37576ebfc1d2950b01c3f7111 /Python/pythonrun.c
parent8dbe5b5568a9755b3e7c0f71df4b26a13893fd68 (diff)
downloadcpython-3f94cbf9eba7adef027cfc5d087b3660800df9d7.zip
cpython-3f94cbf9eba7adef027cfc5d087b3660800df9d7.tar.gz
cpython-3f94cbf9eba7adef027cfc5d087b3660800df9d7.tar.bz2
Actually initialize __main__.__loader__ with loader instances, not the corresponding type objects
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 970834e..8130cc5 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;