File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -1560,10 +1560,11 @@ finalize_remove_modules(PyObject *modules, int verbose)
15601560 * elsewhere, keep the referenced module alive
15611561 * until finalize_modules_clear_weaklist() finishes.
15621562 */ \
1563- tup = PyTuple_Pack (3 , name , wr , mod ); \
1563+ Py_INCREF (mod ); \
1564+ tup = PyTuple_Pack (3 , name , wr , Py_True ); \
15641565 } \
15651566 else { \
1566- tup = PyTuple_Pack (2 , name , wr ); \
1567+ tup = PyTuple_Pack (3 , name , wr , Py_False ); \
15671568 } \
15681569 if (!tup || PyList_Append (weaklist , tup ) < 0 ) { \
15691570 PyErr_FormatUnraisable ("Exception ignored while removing modules" ); \
@@ -1677,6 +1678,9 @@ finalize_modules_clear_weaklist(PyInterpreterState *interp,
16771678 }
16781679 _PyModule_Clear (mod );
16791680 Py_DECREF (mod );
1681+ if (PyTuple_GET_ITEM (tup , 2 ) == Py_True ) {
1682+ Py_DECREF (mod );
1683+ }
16801684 }
16811685}
16821686
You can’t perform that action at this time.
0 commit comments