pybind11::args should have been derived from tuple

args was derived from list, but cpp_function::dispatcher sends a tuple to it->impl (line #346 and #392 in pybind11.h).  As a result args::size() and args::operator[] don't work at all.  On my mac args::size() returns -1.  Making args a subclass of tuple fixes it.
This commit is contained in:
Yung-Yu Chen
2016-05-25 20:54:12 +08:00
parent 1e3be73a52
commit 114bfeb762
2 changed files with 4 additions and 4 deletions

View File

@@ -27,8 +27,8 @@ py::object call_kw_func(py::function f) {
}
void args_function(py::args args) {
for (auto item : args)
std::cout << "got argument: " << item << std::endl;
for (size_t it=0; it<args.size(); ++it)
std::cout << "got argument: " << py::object(args[it]) << std::endl;
}
void args_kwargs_function(py::args args, py::kwargs kwargs) {