Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tune a test
  • Loading branch information
neonene committed Apr 14, 2024
commit a2a53a05640901b36e1ddb617f8b2af87a6375f6
2 changes: 1 addition & 1 deletion Lib/test/test_ctypes/test_refcounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_many_closures_per_module(self):
"cfuncs = [cfunc_type(pyfunc) for i in range(500)];"
"cthunk_tp = type(cfuncs[0]._objects['0']);"
"ismeta = type(cthunk_tp) is not type;"
"n_containers = ismeta and cthunk_tp.ffi_closure_containers_count;"
"n_containers = ismeta and cthunk_tp.get_ffi_closure_containers_count();"
"exit(n_containers and n_containers < 2)"
)
script_helper.assert_python_ok("-c", script)
Expand Down
13 changes: 6 additions & 7 deletions Modules/_ctypes/malloc_closure.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,22 @@ CThunkType_dealloc(PyObject *self)
}

static PyObject *
CThunkType_get_narenas(PyTypeObject *self, void *Py_UNUSED(ignored))
CThunkType_get_narenas(PyObject *self, PyObject *Py_UNUSED(ignored))
{
thunk_type_state *st = get_type_state(self);
thunk_type_state *st = get_type_state((PyTypeObject *)self);
return PyLong_FromSsize_t(st->narenas);
}

static PyGetSetDef CThunkType_getsets[] = {
{"ffi_closure_containers_count", (getter)CThunkType_get_narenas,
NULL, NULL, NULL},
{0}
static PyMethodDef CThunkType_methods[] = {
{"get_ffi_closure_containers_count", CThunkType_get_narenas, METH_NOARGS, NULL},
{0},
};

static PyType_Slot cthunk_type_slots[] = {
{Py_tp_getset, CThunkType_getsets},
{Py_tp_traverse, CThunkType_traverse},
{Py_tp_clear, CThunkType_clear},
{Py_tp_dealloc, CThunkType_dealloc},
{Py_tp_methods, CThunkType_methods},
{0, NULL},
};

Expand Down