File tree 1 file changed +26
-1
lines changed
1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -3536,13 +3536,36 @@ _PyExc_InitTypes(PyInterpreterState *interp)
3536
3536
}
3537
3537
3538
3538
3539
+ static void
3540
+ _PyExc_FiniTypes (PyInterpreterState * interp )
3541
+ {
3542
+ if (!_Py_IsMainInterpreter (interp )) {
3543
+ return ;
3544
+ }
3545
+
3546
+ for (Py_ssize_t i = Py_ARRAY_LENGTH (static_exceptions ) - 1 ; i >= 0 ; i -- ) {
3547
+ PyTypeObject * exc = static_exceptions [i ].exc ;
3548
+
3549
+ // Cannot delete a type if it still has subclasses
3550
+ if (exc -> tp_subclasses != NULL ) {
3551
+ continue ;
3552
+ }
3553
+
3554
+ _PyStaticType_Dealloc (exc );
3555
+ }
3556
+ }
3557
+
3558
+
3539
3559
PyStatus
3540
3560
_PyExc_InitGlobalObjects (PyInterpreterState * interp )
3541
3561
{
3562
+ if (!_Py_IsMainInterpreter (interp )) {
3563
+ return _PyStatus_OK ();
3564
+ }
3565
+
3542
3566
if (preallocate_memerrors () < 0 ) {
3543
3567
return _PyStatus_NO_MEMORY ();
3544
3568
}
3545
-
3546
3569
return _PyStatus_OK ();
3547
3570
}
3548
3571
@@ -3656,6 +3679,8 @@ _PyExc_Fini(PyInterpreterState *interp)
3656
3679
struct _Py_exc_state * state = & interp -> exc_state ;
3657
3680
free_preallocated_memerrors (state );
3658
3681
Py_CLEAR (state -> errnomap );
3682
+
3683
+ _PyExc_FiniTypes (interp );
3659
3684
}
3660
3685
3661
3686
/* Helper to do the equivalent of "raise X from Y" in C, but always using
You can’t perform that action at this time.
0 commit comments