Skip to content

Commit

Permalink
Properly visit self in >=3.9 traverse (#4051)
Browse files Browse the repository at this point in the history
* Properly visit self in >=3.9 traverse

* Add comment about 3.9 behavior
  • Loading branch information
Skylion007 authored Jul 10, 2022
1 parent 432bc5c commit f9f0049
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/pybind11/detail/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ extern "C" inline int pybind11_set_dict(PyObject *self, PyObject *new_dict, void
extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
PyObject *&dict = *_PyObject_GetDictPtr(self);
Py_VISIT(dict);
// https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_traverse
#if PY_VERSION_HEX >= 0x03090000
Py_VISIT(Py_TYPE(self));
#endif
return 0;
}

Expand Down

0 comments on commit f9f0049

Please sign in to comment.