What version (or hash if on master) of pybind11 are you using?
master (0a756c0b)
Problem description
This is a rather strange issue in that any change to the code below causes the issue to not show up.
We define a function with two overloads, one to be called as test_cast(v), and one as test_cast(x=x, v=v), where v is a std::vector<double>. This requires in Python that v be a list of floats, but [5,6,7] is accepted just fine (as it should!).
However, for the second overload, v=[5,6,7] throws an error:
E TypeError: test_cast(): incompatible function arguments. The following argument types are supported:
E 1. (v: list[float]) -> list[float]
E 2. (*, x: float, v: list[float]) -> list[float]
E
E Invoked with: kwargs: x=1.0, v=[5, 6, 7]
This error only happens when kw_only() comes before the first argument in the second overload. If we move it to the second position, all is well again.
I've contributed large fixes to Pybind11 before, but in this case I don't know where to start searching for the error.
To reproduce the error:
This can be added to any of the existing test files to reproduce the problem.
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
master (0a756c0b)
Problem description
This is a rather strange issue in that any change to the code below causes the issue to not show up.
We define a function with two overloads, one to be called as
test_cast(v)
, and one astest_cast(x=x, v=v)
, wherev
is astd::vector<double>
. This requires in Python thatv
be a list of floats, but[5,6,7]
is accepted just fine (as it should!).However, for the second overload,
v=[5,6,7]
throws an error:This error only happens when
kw_only()
comes before the first argument in the second overload. If we move it to the second position, all is well again.I've contributed large fixes to Pybind11 before, but in this case I don't know where to start searching for the error.
To reproduce the error:
This can be added to any of the existing test files to reproduce the problem.
In C++:
In Python:
Reproducible example code
Is this a regression? Put the last known working version here if it is.
Not now if a regression