@@ -337,11 +337,9 @@ Here is an example of the required code for a ``Wrapper`` type:
337337 struct Wrapper { std::shared_ptr<Wrapper> value; };
338338
339339 int wrapper_tp_traverse(PyObject *self, visitproc visit, void *arg) {
340- // On Python 3.9+, we must traverse the implicit dependency
341- // of an object on its associated type object.
342- #if PY_VERSION_HEX >= 0x03090000
343- Py_VISIT(Py_TYPE(self));
344- #endif
340+ // We must traverse the implicit dependency of an object on its
341+ // associated type object.
342+ Py_VISIT(Py_TYPE(self));
345343
346344 // The tp_traverse method may be called after __new__ but before or during
347345 // __init__, before the C++ constructor has been completed. We must not
@@ -454,28 +452,6 @@ how deal with them. For completeness, let's consider some other possibilities.
454452 should be fixed in the responsible framework so that leak warnings aren't
455453 cluttered with flukes and can be more broadly useful.
456454
457- - **Older Python versions **: Very old Python versions (e.g., 3.8) don't
458- do a good job cleaning up global references when the interpreter shuts down.
459- The following code may leak a reference if it is a top-level statement in a
460- Python file or the REPL.
461-
462- .. code-block :: python
463-
464- a = my_ext.MyObject()
465-
466- Such a warning is benign and does not indicate an actual leak. It simply
467- highlights a flaws in the interpreter shutdown logic of old Python versions.
468- Wrap your code into a function to address this issue even on such versions:
469-
470- .. code-block :: python
471-
472- def run ():
473- a = my_ext.MyObject()
474- # ...
475-
476- if __name__ == ' __main__' :
477- run()
478-
479455- **Exceptions **. Some exceptions such as ``AttributeError `` have been observed
480456 to hold references, e.g. to the object which lacked the desired attribute. If
481457 the last exception raised by the program references a nanobind instance, then
0 commit comments