mirror of
https://github.com/python/cpython.git
synced 2025-09-03 07:28:59 +00:00
Actually initialize __main__.__loader__ with loader instances, not the corresponding type objects
This commit is contained in:
parent
8dbe5b5568
commit
3f94cbf9eb
2 changed files with 8 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue