Skip to content

Commit 87711b0

Browse files
committedSep 8, 2024·
nb_type_new(): adaption for older Python versions, follow tp_traverse recommendations in test suite
1 parent b2bed68 commit 87711b0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎src/nb_type.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,9 @@ PyObject *nb_type_new(const type_init_data *t) noexcept {
11761176
*s++ = { Py_tp_members, (void*) members };
11771177

11781178
#if PY_VERSION_HEX < 0x03090000
1179-
(void) is_generic; // unsupported on Python 3.8
1179+
// Features that are unsupported in Python 3.8
1180+
(void) is_generic;
1181+
type_vectorcall = nullptr;
11801182
#else
11811183
if (is_generic)
11821184
*s++ = { Py_tp_methods, (void*) class_getitem_method };

‎tests/test_stl.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ int funcwrapper_tp_traverse(PyObject *self, visitproc visit, void *arg) {
7070
nb::object f = nb::cast(w->f, nb::rv_policy::none);
7171
Py_VISIT(f.ptr());
7272

73+
#if PY_VERSION_HEX >= 0x03090000
74+
Py_VISIT(Py_TYPE(self));
75+
#endif
76+
7377
return 0;
7478
}
7579

0 commit comments

Comments
 (0)
Please sign in to comment.