comparison 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
comparison
equal deleted inserted replaced
78109:87a2f3149ca5 78110:ba264b26d8d9
1353 int 1353 int
1354 set_main_loader(PyObject *d, const char *filename, const char *loader_name) 1354 set_main_loader(PyObject *d, const char *filename, const char *loader_name)
1355 { 1355 {
1356 PyInterpreterState *interp; 1356 PyInterpreterState *interp;
1357 PyThreadState *tstate; 1357 PyThreadState *tstate;
1358 PyObject *loader; 1358 PyObject *loader_type, *loader;
1359 /* Get current thread state and interpreter pointer */ 1359 /* Get current thread state and interpreter pointer */
1360 tstate = PyThreadState_GET(); 1360 tstate = PyThreadState_GET();
1361 interp = tstate->interp; 1361 interp = tstate->interp;
1362 loader = PyObject_GetAttrString(interp->importlib, loader_name); 1362 loader_type = PyObject_GetAttrString(interp->importlib, loader_name);
1363 if (loader_type == NULL) {
1364 return -1;
1365 }
1366 loader = PyObject_CallFunction(loader_type, "ss", "__main__", filename);
1363 if (loader == NULL || 1367 if (loader == NULL ||
1364 (PyDict_SetItemString(d, "__loader__", loader) < 0)) { 1368 (PyDict_SetItemString(d, "__loader__", loader) < 0)) {
1365 return -1; 1369 return -1;
1366 } 1370 }
1367 Py_DECREF(loader); 1371 Py_DECREF(loader);