Skip to content

Commit 9ae6cba

Browse files
committed
Merge branch 'master' into python_multiple_inheritance_test
2 parents 86ca4e1 + f260693 commit 9ae6cba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/pybind11/pybind11.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,10 +2751,15 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char *
27512751
if ((std::string) str(f_code->co_name) == name && f_code->co_argcount > 0) {
27522752
PyObject *locals = PyEval_GetLocals();
27532753
if (locals != nullptr) {
2754+
# if PY_VERSION_HEX >= 0x030b0000
2755+
PyObject *co_varnames = PyCode_GetVarnames(f_code);
2756+
# else
27542757
PyObject *co_varnames = PyObject_GetAttrString((PyObject *) f_code, "co_varnames");
2758+
# endif
27552759
PyObject *self_arg = PyTuple_GET_ITEM(co_varnames, 0);
27562760
Py_DECREF(co_varnames);
27572761
PyObject *self_caller = dict_getitem(locals, self_arg);
2762+
Py_DECREF(locals);
27582763
if (self_caller == self.ptr()) {
27592764
Py_DECREF(f_code);
27602765
Py_DECREF(frame);

0 commit comments

Comments
 (0)