@@ -5,6 +5,9 @@ static PyTypeObject _PyExc_InterpreterError = {
55 PyVarObject_HEAD_INIT (NULL , 0 )
66 .tp_name = "interpreters.InterpreterError" ,
77 .tp_doc = PyDoc_STR ("A cross-interpreter operation failed" ),
8+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC ,
9+ //.tp_traverse = ((PyTypeObject *)PyExc_BaseException)->tp_traverse,
10+ //.tp_clear = ((PyTypeObject *)PyExc_BaseException)->tp_clear,
811 //.tp_base = (PyTypeObject *)PyExc_BaseException,
912};
1013PyObject * PyExc_InterpreterError = (PyObject * )& _PyExc_InterpreterError ;
@@ -15,6 +18,9 @@ static PyTypeObject _PyExc_InterpreterNotFoundError = {
1518 PyVarObject_HEAD_INIT (NULL , 0 )
1619 .tp_name = "interpreters.InterpreterNotFoundError" ,
1720 .tp_doc = PyDoc_STR ("An interpreter was not found" ),
21+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC ,
22+ //.tp_traverse = ((PyTypeObject *)PyExc_BaseException)->tp_traverse,
23+ //.tp_clear = ((PyTypeObject *)PyExc_BaseException)->tp_clear,
1824 .tp_base = & _PyExc_InterpreterError ,
1925};
2026PyObject * PyExc_InterpreterNotFoundError = (PyObject * )& _PyExc_InterpreterNotFoundError ;
@@ -55,16 +61,25 @@ _get_not_shareable_error_type(PyInterpreterState *interp)
5561static int
5662init_exceptions (PyInterpreterState * interp )
5763{
64+ PyTypeObject * base = (PyTypeObject * )PyExc_BaseException ;
65+
5866 // builtin static types
59- _PyExc_InterpreterError .tp_base = (PyTypeObject * )PyExc_BaseException ;
67+
68+ _PyExc_InterpreterError .tp_base = base ;
69+ _PyExc_InterpreterError .tp_traverse = base -> tp_traverse ;
70+ _PyExc_InterpreterError .tp_clear = base -> tp_clear ;
6071 if (_PyStaticType_InitBuiltin (interp , & _PyExc_InterpreterError ) < 0 ) {
6172 return -1 ;
6273 }
74+
75+ _PyExc_InterpreterNotFoundError .tp_traverse = base -> tp_traverse ;
76+ _PyExc_InterpreterNotFoundError .tp_clear = base -> tp_clear ;
6377 if (_PyStaticType_InitBuiltin (interp , & _PyExc_InterpreterNotFoundError ) < 0 ) {
6478 return -1 ;
6579 }
6680
6781 // heap types
82+
6883 // We would call _init_not_shareable_error_type() here too,
6984 // but that leads to ref leaks
7085
0 commit comments