diff options
author | Larry Hastings <larry@hastings.org> | 2014-05-17 21:05:10 -0700 |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2014-05-17 21:05:10 -0700 |
commit | 3a260d228b32b04a88d947b887bf81759e8e5f10 (patch) | |
tree | e4a34e9cbbf877cf021ffba743ddbf54e17526b7 /Python/import.c | |
parent | 2110603344316d927e6d639275c12f5da78601d5 (diff) | |
parent | b1a1ec3151155a1ae65831793b4a5b7a87d9d09f (diff) | |
download | cpython-git-3a260d228b32b04a88d947b887bf81759e8e5f10.tar.gz |
Merge.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/Python/import.c b/Python/import.c index 0e26ffcd94..4c8f67f499 100644 --- a/Python/import.c +++ b/Python/import.c @@ -856,7 +856,7 @@ module_dict_for_exec(PyObject *name) } } - return d; + return d; /* Return a borrowed reference. */ } static PyObject * @@ -888,33 +888,25 @@ PyObject* PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname, PyObject *cpathname) { - PyObject *d, *v; + PyObject *d, *res; + PyInterpreterState *interp = PyThreadState_GET()->interp; + _Py_IDENTIFIER(_fix_up_module); d = module_dict_for_exec(name); if (d == NULL) { return NULL; } - if (pathname != NULL) { - v = pathname; + if (pathname == NULL) { + pathname = ((PyCodeObject *)co)->co_filename; } - else { - v = ((PyCodeObject *)co)->co_filename; + res = _PyObject_CallMethodIdObjArgs(interp->importlib, + &PyId__fix_up_module, + d, name, pathname, cpathname, NULL); + if (res != NULL) { + res = exec_code_in_module(name, d, co); } - Py_INCREF(v); - if (PyDict_SetItemString(d, "__file__", v) != 0) - PyErr_Clear(); /* Not important enough to report */ - Py_DECREF(v); - - /* Remember the pyc path name as the __cached__ attribute. */ - if (cpathname != NULL) - v = cpathname; - else - v = Py_None; - if (PyDict_SetItemString(d, "__cached__", v) != 0) - PyErr_Clear(); /* Not important enough to report */ - - return exec_code_in_module(name, d, co); + return res; } |