mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Merge from 3.4 (for #21226).
This commit is contained in:
commit
b7f1be309e
5 changed files with 4331 additions and 4281 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
8547
Python/importlib.h
8547
Python/importlib.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue