diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2017-09-14 06:46:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-14 06:46:04 (GMT) |
commit | 93c92f7d1dbb6e7e472f1d0444c6968858113de2 (patch) | |
tree | 031230f9b0cf2e8a8ef21f7fc40c4f5f98d20c6c /Modules/pyexpat.c | |
parent | 13ad3b7a82bf56d803fbe48ee5df6c4b08986c78 (diff) | |
download | cpython-93c92f7d1dbb6e7e472f1d0444c6968858113de2.zip cpython-93c92f7d1dbb6e7e472f1d0444c6968858113de2.tar.gz cpython-93c92f7d1dbb6e7e472f1d0444c6968858113de2.tar.bz2 |
bpo-31404: Revert "remove modules from Py_InterpreterState (#1638)" (#3565)
PR #1638, for bpo-28411, causes problems in some (very) edge cases. Until that gets sorted out, we're reverting the merge. PR #3506, a fix on top of #1638, is also getting reverted.
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r-- | Modules/pyexpat.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index c8a01d4..d9cfa3e 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1643,6 +1643,7 @@ MODULE_INITFUNC(void) PyObject *errors_module; PyObject *modelmod_name; PyObject *model_module; + PyObject *sys_modules; PyObject *tmpnum, *tmpstr; PyObject *codes_dict; PyObject *rev_codes_dict; @@ -1692,6 +1693,11 @@ MODULE_INITFUNC(void) */ PyModule_AddStringConstant(m, "native_encoding", "UTF-8"); + sys_modules = PySys_GetObject("modules"); + if (sys_modules == NULL) { + Py_DECREF(m); + return NULL; + } d = PyModule_GetDict(m); if (d == NULL) { Py_DECREF(m); @@ -1701,7 +1707,7 @@ MODULE_INITFUNC(void) if (errors_module == NULL) { errors_module = PyModule_New(MODULE_NAME ".errors"); if (errors_module != NULL) { - _PyImport_SetModule(errmod_name, errors_module); + PyDict_SetItem(sys_modules, errmod_name, errors_module); /* gives away the reference to errors_module */ PyModule_AddObject(m, "errors", errors_module); } @@ -1711,7 +1717,7 @@ MODULE_INITFUNC(void) if (model_module == NULL) { model_module = PyModule_New(MODULE_NAME ".model"); if (model_module != NULL) { - _PyImport_SetModule(modelmod_name, model_module); + PyDict_SetItem(sys_modules, modelmod_name, model_module); /* gives away the reference to model_module */ PyModule_AddObject(m, "model", model_module); } |