diff options
| author | Eric Snow <ericsnowcurrently@gmail.com> | 2014-05-12 18:25:00 -0600 |
|---|---|---|
| committer | Eric Snow <ericsnowcurrently@gmail.com> | 2014-05-12 18:25:00 -0600 |
| commit | b7f1be309eb7d2deceb8b6c3f3a4de1e4dcbbe11 (patch) | |
| tree | 657316c7a5016968c0e031e057250a5670db388e /Python/import.c | |
| parent | 38d3d22b29abed5a92166b86dddbbc575cf4ae02 (diff) | |
| parent | 08197a4616f6294e21672fd8ebb5da7ce956c8e5 (diff) | |
| download | cpython-git-b7f1be309eb7d2deceb8b6c3f3a4de1e4dcbbe11.tar.gz | |
Merge from 3.4 (for #21226).
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; } |
