Fix garbage collection issue with closure in Python 3.10

This commit is contained in:
Jeremy Rimpo
2021-12-09 16:46:39 -06:00
parent 11c2bcac9a
commit 7e8748abf0
+2 -6
View File
@@ -19,10 +19,8 @@ namespace details {
*/
template <class ReturnType, class WrapperTypePtr, class Fn, class... Args>
ReturnType wrapperFunctionImplementation(WrapperTypePtr wrapper, bool apiTransfer, Fn fn, boost::python::object* objPtr, const char *methodName, Args... args) {
boost::python::override implementation = [&]() {
GILock lock;
return wrapper->get_override(methodName);
}();
GILock lock;
auto implementation = wrapper->get_override(methodName);
if (!implementation) {
if constexpr (std::is_same_v<Fn, std::nullptr_t>) {
throw pyexcept::MissingImplementation(wrapper->className, methodName);
@@ -31,8 +29,6 @@ namespace details {
return std::invoke(fn, wrapper, args...);
}
}
GILock lock;
try {
boost::python::object result = implementation(args...);
if (objPtr) {