Skip to content

Commit

Permalink
fix: only apply leak on 3.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Oct 12, 2020
1 parent 61e40f6 commit bebdbd2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,15 @@ class cpp_function : public function {
}
if (rec->def) {
std::free(const_cast<char *>(rec->def->ml_doc));
//delete rec->def;
// Python 3.9.0 decref's these in the wrong order; rec->def
// If loaded on 3.9.0, let these leak (use Python 3.9.1 to fix)
// See https://github.com/python/cpython/pull/22670
#if !defined(PYPY_VERSION) && PY_MAJOR_VERSION == 3 && PY_MINOR_VERISON == 9
if(Py_GetVersion()[4] != '0')
delete rec->def;
#else
delete rec->def;
#endif
}
delete rec;
rec = next;
Expand Down

0 comments on commit bebdbd2

Please sign in to comment.