diff Python/pythonrun.c @ 78110:ba264b26d8d9

Actually initialize __main__.__loader__ with loader instances, not the corresponding type objects
author Nick Coghlan <ncoghlan@gmail.com>
date Sun, 15 Jul 2012 19:10:39 +1000
parents 3987667bf98f
children 8bf691d0b004
line wrap: on
line diff
--- a/Python/pythonrun.c	Sun Jul 15 18:29:24 2012 +1000
+++ b/Python/pythonrun.c	Sun Jul 15 19:10:39 2012 +1000
@@ -1355,11 +1355,15 @@
 {
     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;