diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cb3f22dfa..1271c2afe5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -119,8 +119,10 @@ repos: args: ["-x.codespell-ignore-lines", "-Lccompiler,intstruct"] # Also check spelling -- repo: https://github.com/crate-ci/typos - rev: v1 +# Use mirror because pre-commit autoupdate confuses tags in the upstream repo. +# See https://github.com/crate-ci/typos/issues/390 +- repo: https://github.com/adhtruong/mirrors-typos + rev: "v1.41.0" hooks: - id: typos args: [] diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 45e8e46f89..c457e149c1 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1081,7 +1081,10 @@ class cpp_function : public function { dict kwargs; for (size_t i = 0; i < used_kwargs.size(); ++i) { if (!used_kwargs[i]) { - kwargs[PyTuple_GET_ITEM(kwnames_in, i)] = args_in_arr[n_args_in + i]; + // Fetch value before indexing into kwargs to ensure well-defined + // evaluation order (MSVC C4866). + PyObject *const arg_in_arr = args_in_arr[n_args_in + i]; + kwargs[PyTuple_GET_ITEM(kwnames_in, i)] = arg_in_arr; } } call.args.push_back(kwargs);