summaryrefslogtreecommitdiffstats
path: root/Objects/moduleobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-10 16:21:34 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-10 16:21:34 (GMT)
commit013bb91aa304062bb65fe8951e2d263f2065ee56 (patch)
tree27febdf4f9bb1022798cdf8f44eef801987064e9 /Objects/moduleobject.c
parent761412246751bbf32bfa6315a9888d6cbf322ee5 (diff)
downloadcpython-013bb91aa304062bb65fe8951e2d263f2065ee56.zip
cpython-013bb91aa304062bb65fe8951e2d263f2065ee56.tar.gz
cpython-013bb91aa304062bb65fe8951e2d263f2065ee56.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.c13
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;