Skip to content

Commit 2efbea6

Browse files
committed
fix: handle MSVC warning C4866: compiler may not enforce left-to-right evaluation order
1 parent c630e22 commit 2efbea6

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

include/pybind11/detail/function_record_pyobject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "common.h"
1414

1515
#include <cstring>
16+
#include <utility>
1617

1718
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
1819
PYBIND11_NAMESPACE_BEGIN(detail)
@@ -188,11 +189,10 @@ inline PyObject *reduce_ex_impl(PyObject *self, PyObject *, PyObject *) {
188189
&& PyModule_Check(rec->scope.ptr()) != 0) {
189190
object scope_module = get_scope_module(rec->scope);
190191
if (scope_module) {
191-
return make_tuple(reinterpret_borrow<object>(PyEval_GetBuiltins())["eval"],
192-
make_tuple(str("__import__('importlib').import_module('")
193-
+ scope_module + str("')")))
194-
.release()
195-
.ptr();
192+
auto py_eval = reinterpret_borrow<dict>(PyEval_GetBuiltins())["eval"];
193+
auto reconstruct_args = make_tuple(str("__import__('importlib').import_module('")
194+
+ scope_module + str("')"));
195+
return make_tuple(std::move(py_eval), std::move(reconstruct_args)).release().ptr();
196196
}
197197
}
198198
set_error(PyExc_RuntimeError, repr(self) + str(" is not pickleable."));

0 commit comments

Comments
 (0)