comparison Python/pythonrun.c @ 83623:7de9852cdc0e 3.3

Fix crash caused by 8c1385205a35 (thanks Arfrever for reporting).
author Antoine Pitrou <solipsis@pitrou.net>
date Sun, 05 May 2013 08:12:42 +0200
parents 8c1385205a35
children 19ce90930e8b 6f4627a65c0a
comparison
equal deleted inserted replaced
83621:996a937cdf81 83623:7de9852cdc0e
556 #endif 556 #endif
557 557
558 /* Destroy the database used by _PyImport_{Fixup,Find}Extension */ 558 /* Destroy the database used by _PyImport_{Fixup,Find}Extension */
559 _PyImport_Fini(); 559 _PyImport_Fini();
560 560
561 /* Cleanup typeobject.c's internal caches. */
562 _PyType_Fini();
563
561 /* unload faulthandler module */ 564 /* unload faulthandler module */
562 _PyFaulthandler_Fini(); 565 _PyFaulthandler_Fini();
563 566
564 /* Debugging stuff */ 567 /* Debugging stuff */
565 #ifdef COUNT_ALLOCS 568 #ifdef COUNT_ALLOCS
576 */ 579 */
577 if (Py_GETENV("PYTHONDUMPREFS")) 580 if (Py_GETENV("PYTHONDUMPREFS"))
578 _Py_PrintReferences(stderr); 581 _Py_PrintReferences(stderr);
579 #endif /* Py_TRACE_REFS */ 582 #endif /* Py_TRACE_REFS */
580 583
581 /* Clear interpreter state */ 584 /* Clear interpreter state and all thread states. */
582 PyInterpreterState_Clear(interp); 585 PyInterpreterState_Clear(interp);
583 586
584 /* Now we decref the exception classes. After this point nothing 587 /* Now we decref the exception classes. After this point nothing
585 can raise an exception. That's okay, because each Fini() method 588 can raise an exception. That's okay, because each Fini() method
586 below has been checked to make sure no exceptions are ever 589 below has been checked to make sure no exceptions are ever
591 594
592 /* Cleanup auto-thread-state */ 595 /* Cleanup auto-thread-state */
593 #ifdef WITH_THREAD 596 #ifdef WITH_THREAD
594 _PyGILState_Fini(); 597 _PyGILState_Fini();
595 #endif /* WITH_THREAD */ 598 #endif /* WITH_THREAD */
596
597 /* Delete current thread */
598 PyThreadState_Swap(NULL);
599 PyInterpreterState_Delete(interp);
600 599
601 /* Sundry finalizers */ 600 /* Sundry finalizers */
602 PyMethod_Fini(); 601 PyMethod_Fini();
603 PyFrame_Fini(); 602 PyFrame_Fini();
604 PyCFunction_Fini(); 603 PyCFunction_Fini();
609 PyByteArray_Fini(); 608 PyByteArray_Fini();
610 PyLong_Fini(); 609 PyLong_Fini();
611 PyFloat_Fini(); 610 PyFloat_Fini();
612 PyDict_Fini(); 611 PyDict_Fini();
613 PySlice_Fini(); 612 PySlice_Fini();
614 _PyType_Fini();
615 613
616 /* Cleanup Unicode implementation */ 614 /* Cleanup Unicode implementation */
617 _PyUnicode_Fini(); 615 _PyUnicode_Fini();
616
617 /* Delete current thread. After this, many C API calls become crashy. */
618 PyThreadState_Swap(NULL);
619 PyInterpreterState_Delete(interp);
618 620
619 /* reset file system default encoding */ 621 /* reset file system default encoding */
620 if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) { 622 if (!Py_HasFileSystemDefaultEncoding && Py_FileSystemDefaultEncoding) {
621 free((char*)Py_FileSystemDefaultEncoding); 623 free((char*)Py_FileSystemDefaultEncoding);
622 Py_FileSystemDefaultEncoding = NULL; 624 Py_FileSystemDefaultEncoding = NULL;