Issue #19255: The builtins module is restored to initial value before

cleaning other modules.  The sys and builtins modules are cleaned last.
This commit is contained in:
Serhiy Storchaka 2014-02-10 18:21:34 +02:00
parent 8f9f0f12e8
commit 87a5c515d0
7 changed files with 96 additions and 39 deletions

View file

@ -298,6 +298,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
@ -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;