File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -606,11 +606,6 @@ Py_Finalize(void)
606606
607607 _PyExc_Fini ();
608608
609- /* Cleanup auto-thread-state */
610- #ifdef WITH_THREAD
611- _PyGILState_Fini ();
612- #endif /* WITH_THREAD */
613-
614609 /* Sundry finalizers */
615610 PyMethod_Fini ();
616611 PyFrame_Fini ();
@@ -629,10 +624,6 @@ Py_Finalize(void)
629624 /* Cleanup Unicode implementation */
630625 _PyUnicode_Fini ();
631626
632- /* Delete current thread. After this, many C API calls become crashy. */
633- PyThreadState_Swap (NULL );
634- PyInterpreterState_Delete (interp );
635-
636627 /* reset file system default encoding */
637628 if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding ) {
638629 free ((char * )Py_FileSystemDefaultEncoding );
@@ -647,6 +638,15 @@ Py_Finalize(void)
647638
648639 PyGrammar_RemoveAccelerators (& _PyParser_Grammar );
649640
641+ /* Cleanup auto-thread-state */
642+ #ifdef WITH_THREAD
643+ _PyGILState_Fini ();
644+ #endif /* WITH_THREAD */
645+
646+ /* Delete current thread. After this, many C API calls become crashy. */
647+ PyThreadState_Swap (NULL );
648+ PyInterpreterState_Delete (interp );
649+
650650#ifdef Py_TRACE_REFS
651651 /* Display addresses (& refcnts) of all objects still alive.
652652 * An address can be used to find the repr of the object, printed
You can’t perform that action at this time.
0 commit comments