Skip to content

Commit 4d63def

Browse files
Update eventbinder (#268)
Co-authored-by: Matthieu Dartiailh <m.dartiailh@gmail.com>
1 parent c6e0de7 commit 4d63def

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

atom/src/eventbinder.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ EventBinder_traverse( EventBinder* self, visitproc visit, void* arg )
3636
{
3737
Py_VISIT( self->member );
3838
Py_VISIT( self->atom );
39-
#if PY_VERSION_HEX >= 0x03090000
40-
// This was not needed before Python 3.9 (Python issue 35810 and 40217)
4139
Py_VISIT(Py_TYPE(self));
42-
#endif
4340
return 0;
4441
}
4542

@@ -52,7 +49,11 @@ EventBinder_dealloc( EventBinder* self )
5249
if( numfree < FREELIST_MAX )
5350
freelist[ numfree++ ] = self;
5451
else
55-
Py_TYPE(self)->tp_free( pyobject_cast( self ) );
52+
{
53+
PyTypeObject* tp = Py_TYPE( self );
54+
tp->tp_free( pyobject_cast( self ) );
55+
Py_DECREF( tp );
56+
}
5657
}
5758

5859

@@ -168,6 +169,7 @@ EventBinder::New( Member* member, CAtom* atom )
168169
{
169170
pybinder = pyobject_cast( freelist[ --numfree ] );
170171
_Py_NewReference( pybinder );
172+
PyObject_GC_Track( pybinder );
171173
}
172174
else
173175
{

0 commit comments

Comments
 (0)