diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-10 16:21:34 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-10 16:21:34 (GMT) |
commit | 87a5c515d03f3e2215f3da7b90a4b848ac510879 (patch) | |
tree | 84a23e66140538f0d8b870379826b809be2c65b7 /Objects/moduleobject.c | |
parent | 8f9f0f12e845034080525c6a80d52215533cb2a4 (diff) | |
download | cpython-87a5c515d03f3e2215f3da7b90a4b848ac510879.zip cpython-87a5c515d03f3e2215f3da7b90a4b848ac510879.tar.gz cpython-87a5c515d03f3e2215f3da7b90a4b848ac510879.tar.bz2 |
Issue #19255: The builtins module is restored to initial value before
cleaning other modules. The sys and builtins modules are cleaned last.
Diffstat (limited to 'Objects/moduleobject.c')
-rw-r--r-- | Objects/moduleobject.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index d59475e..6821710 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -299,6 +299,14 @@ PyModule_GetState(PyObject* m) void _PyModule_Clear(PyObject *m) { + PyObject *d = ((PyModuleObject *)m)->md_dict; + if (d != NULL) + _PyModule_ClearDict(d); +} + +void +_PyModule_ClearDict(PyObject *d) +{ /* To make the execution order of destructors for global objects a bit more predictable, we first zap all objects whose name starts with a single underscore, before we clear @@ -308,11 +316,6 @@ _PyModule_Clear(PyObject *m) Py_ssize_t pos; PyObject *key, *value; - PyObject *d; - - d = ((PyModuleObject *)m)->md_dict; - if (d == NULL) - return; /* First, clear only names starting with a single underscore */ pos = 0; |