Fix memory leak when calling Python from Rust

This commit is contained in:
Peter Schafhalter 2021-08-17 14:21:56 -07:00
parent fc90092ef9
commit cf39181efd
1 changed files with 1 additions and 0 deletions

View File

@ -396,6 +396,7 @@ impl<'p> Python<'p> {
return Err(PyErr::api_call_failed(self));
}
let res_ptr = ffi::PyEval_EvalCode(code_obj, globals, locals);
ffi::Py_DECREF(code_obj);
self.from_owned_ptr_or_err(res_ptr)
}