Skip to content

Commit b4b9331

Browse files
authored
Fix off-by-one error in nb::call_policy documentation (#911)
1 parent b9af9d4 commit b4b9331

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/api_core.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,14 +1998,14 @@ parameter of :cpp:func:`module_::def`, :cpp:func:`class_::def`,
19981998
static void postcall(PyObject **args,
19991999
std::integral_constant<size_t, N>,
20002000
nb::handle ret) {
2001-
static_assert(I > 0 && I < N,
2001+
static_assert(I > 0 && I <= N,
20022002
"I in returns_references_to<I> must be in the "
20032003
"range [1, number of C++ function arguments]");
20042004
if (!nb::isinstance<nb::sequence>(ret)) {
20052005
throw std::runtime_error("return value should be a sequence");
20062006
}
20072007
for (nb::handle nurse : ret) {
2008-
nb::detail::keep_alive(nurse.ptr(), args[I]);
2008+
nb::detail::keep_alive(nurse.ptr(), args[I - 1]);
20092009
}
20102010
}
20112011
};

0 commit comments

Comments
 (0)