diff options
author | Larry Hastings <larry@hastings.org> | 2015-08-25 14:13:55 -0700 |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2015-08-25 14:13:55 -0700 |
commit | 06a7d611da25fab11b7a7ab7a7f0bbce7d6a65fd (patch) | |
tree | 9cdef304ed52f796f1001fdb8e170845d1d4ba61 /Python/import.c | |
parent | 36f22a2820d4e2dc31720e90ccc14050838081ad (diff) | |
parent | 9126d5499e7a634c9c9f2619ea6e961ff3b84662 (diff) | |
download | cpython-git-06a7d611da25fab11b7a7ab7a7f0bbce7d6a65fd.tar.gz |
Merge from Python 3.5.0 (rc2) to Python 3.5.1.
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/Python/import.c b/Python/import.c index 44aae80990..edf030d87a 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1943,6 +1943,34 @@ _imp_is_frozen_impl(PyModuleDef *module, PyObject *name) return PyBool_FromLong((long) (p == NULL ? 0 : p->size)); } +/* Common implementation for _imp.exec_dynamic and _imp.exec_builtin */ +static int +exec_builtin_or_dynamic(PyObject *mod) { + PyModuleDef *def; + void *state; + + if (!PyModule_Check(mod)) { + return 0; + } + + def = PyModule_GetDef(mod); + if (def == NULL) { + if (PyErr_Occurred()) { + return -1; + } + return 0; + } + state = PyModule_GetState(mod); + if (PyErr_Occurred()) { + return -1; + } + if (state) { + /* Already initialized; skip reload */ + return 0; + } + return PyModule_ExecDef(mod, def); +} + #ifdef HAVE_DYNAMIC_LOADING /*[clinic input] @@ -2014,35 +2042,29 @@ static int _imp_exec_dynamic_impl(PyModuleDef *module, PyObject *mod) /*[clinic end generated code: output=4b84f1301b22d4bd input=9fdbfcb250280d3a]*/ { - PyModuleDef *def; - void *state; - - if (!PyModule_Check(mod)) { - return 0; - } - - def = PyModule_GetDef(mod); - if (def == NULL) { - if (PyErr_Occurred()) { - return -1; - } - return 0; - } - state = PyModule_GetState(mod); - if (PyErr_Occurred()) { - return -1; - } - if (state) { - /* Already initialized; skip reload */ - return 0; - } - return PyModule_ExecDef(mod, def); + return exec_builtin_or_dynamic(mod); } #endif /* HAVE_DYNAMIC_LOADING */ /*[clinic input] +_imp.exec_builtin -> int + + mod: object + / + +Initialize a built-in module. +[clinic start generated code]*/ + +static int +_imp_exec_builtin_impl(PyModuleDef *module, PyObject *mod) +/*[clinic end generated code: output=215e99876a27e284 input=7beed5a2f12a60ca]*/ +{ + return exec_builtin_or_dynamic(mod); +} + +/*[clinic input] dump buffer [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ @@ -2064,6 +2086,7 @@ static PyMethodDef imp_methods[] = { _IMP_IS_FROZEN_METHODDEF _IMP_CREATE_DYNAMIC_METHODDEF _IMP_EXEC_DYNAMIC_METHODDEF + _IMP_EXEC_BUILTIN_METHODDEF _IMP__FIX_CO_FILENAME_METHODDEF {NULL, NULL} /* sentinel */ }; |