Skip to content

Commit 002c05b

Browse files
authored
fix: handle MSVC warning C4866: compiler may not enforce left-to-right evaluation order (#5641)
1 parent a265a4c commit 002c05b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

include/pybind11/detail/function_record_pyobject.h

+6-3
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,9 +189,11 @@ 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("')")))
192+
auto builtins = reinterpret_borrow<dict>(PyEval_GetBuiltins());
193+
auto builtins_eval = builtins["eval"];
194+
auto reconstruct_args = make_tuple(str("__import__('importlib').import_module('")
195+
+ scope_module + str("')"));
196+
return make_tuple(std::move(builtins_eval), std::move(reconstruct_args))
194197
.release()
195198
.ptr();
196199
}

0 commit comments

Comments
 (0)