Skip to content

Commit 9abace7

Browse files
committed
add missing tp_free slot for weakref type.
1 parent e953cfb commit 9abace7

File tree

1 file changed

+8
-2
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+8
-2
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,6 @@ picklebuf_getbuf(PyPickleBufferObject *self, Py_buffer *view, int flags)
319319

320320
static void empty_releasebuf(PyObject *self, Py_buffer *view) {}
321321

322-
static int dummy_traverse(PyObject *self, visitproc f, void *i) {return 0;}
323-
324322
static void initialize_bufferprocs() {
325323
static PyBufferProcs bytes_as_buffer = {
326324
(getbufferproc)bytes_buffer_getbuffer, /* bf_getbuffer */
@@ -355,7 +353,14 @@ static void initialize_bufferprocs() {
355353
PyPickleBuffer_Type.tp_as_buffer = &picklebuf_as_buffer;
356354
GraalPy_set_PyTypeObject_tp_as_buffer(&PyPickleBuffer_Type, &picklebuf_as_buffer);
357355

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() {
358362
_PyExc_Exception.tp_traverse = &dummy_traverse;
363+
_PyWeakref_RefType.tp_free = &GraalPyObject_GC_Del;
359364
}
360365

361366
int is_builtin_type(PyTypeObject *tp) {
@@ -899,6 +904,7 @@ PyAPI_FUNC(void) initialize_graal_capi(TruffleEnv* env, void **builtin_closures,
899904
initialize_exceptions();
900905
initialize_hashes();
901906
initialize_bufferprocs();
907+
initialize_gc_types_related_slots();
902908
_PyFloat_InitState(NULL);
903909

904910
// TODO: initialize during cext initialization doesn't work at the moment

0 commit comments

Comments
 (0)