@@ -319,8 +319,6 @@ picklebuf_getbuf(PyPickleBufferObject *self, Py_buffer *view, int flags)
319
319
320
320
static void empty_releasebuf (PyObject * self , Py_buffer * view ) {}
321
321
322
- static int dummy_traverse (PyObject * self , visitproc f , void * i ) {return 0 ;}
323
-
324
322
static void initialize_bufferprocs () {
325
323
static PyBufferProcs bytes_as_buffer = {
326
324
(getbufferproc )bytes_buffer_getbuffer , /* bf_getbuffer */
@@ -355,7 +353,14 @@ static void initialize_bufferprocs() {
355
353
PyPickleBuffer_Type .tp_as_buffer = & picklebuf_as_buffer ;
356
354
GraalPy_set_PyTypeObject_tp_as_buffer (& PyPickleBuffer_Type , & picklebuf_as_buffer );
357
355
356
+ }
357
+
358
+
359
+ static int dummy_traverse (PyObject * self , visitproc f , void * i ) {return 0 ;}
360
+
361
+ static void initialize_gc_types_related_slots () {
358
362
_PyExc_Exception .tp_traverse = & dummy_traverse ;
363
+ _PyWeakref_RefType .tp_free = & GraalPyObject_GC_Del ;
359
364
}
360
365
361
366
int is_builtin_type (PyTypeObject * tp ) {
@@ -899,6 +904,7 @@ PyAPI_FUNC(void) initialize_graal_capi(TruffleEnv* env, void **builtin_closures,
899
904
initialize_exceptions ();
900
905
initialize_hashes ();
901
906
initialize_bufferprocs ();
907
+ initialize_gc_types_related_slots ();
902
908
_PyFloat_InitState (NULL );
903
909
904
910
// TODO: initialize during cext initialization doesn't work at the moment
0 commit comments