diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-05 08:14:53 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-05-05 08:14:53 +0200 |
commit | 9c7387a8ebc5835128633d38094e1bbb00ea874d (patch) | |
tree | ef77f7a56a74616a52c68c41904c8ad5eb2d13b6 /Python | |
parent | 1028c31378f3db5d176647d92e852b855a623525 (diff) | |
parent | 2fbf6d1137a0bb3915acba8eb1f43c11d353205a (diff) | |
download | cpython-9c7387a8ebc5835128633d38094e1bbb00ea874d.tar.gz |
Fix crash caused by 8c1385205a35
(thanks Arfrever for reporting).
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pythonrun.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index cf2ecf1cb1..96b0988ec7 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -576,6 +576,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(); @@ -596,7 +599,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 @@ -612,10 +615,6 @@ Py_Finalize(void) _PyGILState_Fini(); #endif /* WITH_THREAD */ - /* Delete current thread */ - PyThreadState_Swap(NULL); - PyInterpreterState_Delete(interp); - /* Sundry finalizers */ PyMethod_Fini(); PyFrame_Fini(); @@ -629,11 +628,14 @@ Py_Finalize(void) PyFloat_Fini(); PyDict_Fini(); PySlice_Fini(); - _PyType_Fini(); /* 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); |