summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2013-05-12 11:24:47 +0200
committerGeorg Brandl <georg@python.org>2013-05-12 11:24:47 +0200
commit5d95c895920465d8d6c3ff26d9eb2f4b16801112 (patch)
tree959aea0410e24d0b3b9c01fea000ec712e01d6a0 /Python/pythonrun.c
parente88bd351d9d127ea92dfaebb86139d7519c663f9 (diff)
parent8eb9a1bc6a7e9e626f972c555d84235c7cb1de68 (diff)
downloadcpython-5d95c895920465d8d6c3ff26d9eb2f4b16801112.tar.gz
merge heads
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index ee6071e631..9ef653b57a 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -506,9 +506,6 @@ Py_Finalize(void)
/* Disable signal handling */
PyOS_FiniInterrupts();
- /* Clear type lookup cache */
- PyType_ClearCache();
-
/* Collect garbage. This may call finalizers; it's nice to call these
* before all modules are destroyed.
* XXX If a __del__ or weakref callback is triggered here, and tries to
@@ -561,6 +558,9 @@ Py_Finalize(void)
/* Destroy the database used by _PyImport_{Fixup,Find}Extension */
_PyImport_Fini();
+ /* Cleanup typeobject.c's internal caches. */
+ _PyType_Fini();
+
/* unload faulthandler module */
_PyFaulthandler_Fini();
@@ -581,7 +581,7 @@ Py_Finalize(void)
_Py_PrintReferences(stderr);
#endif /* Py_TRACE_REFS */
- /* Clear interpreter state */
+ /* Clear interpreter state and all thread states. */
PyInterpreterState_Clear(interp);
/* Now we decref the exception classes. After this point nothing
@@ -597,10 +597,6 @@ Py_Finalize(void)
_PyGILState_Fini();
#endif /* WITH_THREAD */
- /* Delete current thread */
- PyThreadState_Swap(NULL);
- PyInterpreterState_Delete(interp);
-
/* Sundry finalizers */
PyMethod_Fini();
PyFrame_Fini();
@@ -618,6 +614,10 @@ Py_Finalize(void)
/* Cleanup Unicode implementation */
_PyUnicode_Fini();
+ /* Delete current thread. After this, many C API calls become crashy. */
+ PyThreadState_Swap(NULL);
+ PyInterpreterState_Delete(interp);
+
/* reset file system default encoding */
if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) {
free((char*)Py_FileSystemDefaultEncoding);