From 16db1bfbd70dd67b5cbe6ffe03f876dfae1c69ff Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Sat, 3 Sep 2016 17:25:40 +0200 Subject: [PATCH] Remove superseded handle::operator() overloads The variadic handle::operator() offers the same functionality as well as mixed positional, keyword, * and ** arguments. The tests are also superseded by the ones in `test_callbacks`. --- include/pybind11/cast.h | 14 -------------- include/pybind11/pytypes.h | 2 -- tests/test_kwargs_and_defaults.cpp | 9 --------- tests/test_kwargs_and_defaults.py | 7 ++----- 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 3c39841fc..de185c270 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1134,20 +1134,6 @@ template (std::forward(args)...); } -inline object handle::operator()(detail::args_proxy args) const { - object result(PyObject_CallObject(m_ptr, args.ptr()), false); - if (!result) - throw error_already_set(); - return result; -} - -inline object handle::operator()(detail::args_proxy args, detail::kwargs_proxy kwargs) const { - object result(PyObject_Call(m_ptr, args.ptr(), kwargs.ptr()), false); - if (!result) - throw error_already_set(); - return result; -} - template dict::dict(Args &&...args) : dict(detail::unpacking_collector<>(std::forward(args)...).kwargs()) { } diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index e25f1a794..da22bbd32 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -48,8 +48,6 @@ public: object call(Args&&... args) const; template object operator()(Args&&... args) const; - inline object operator()(detail::args_proxy args) const; - inline object operator()(detail::args_proxy f_args, detail::kwargs_proxy kwargs) const; operator bool() const { return m_ptr != nullptr; } bool operator==(const handle &h) const { return m_ptr == h.m_ptr; } bool operator!=(const handle &h) const { return m_ptr != h.m_ptr; } diff --git a/tests/test_kwargs_and_defaults.cpp b/tests/test_kwargs_and_defaults.cpp index d35ca02ac..24fc0cd5b 100644 --- a/tests/test_kwargs_and_defaults.cpp +++ b/tests/test_kwargs_and_defaults.cpp @@ -20,13 +20,6 @@ std::string kw_func4(const std::vector &entries) { return ret; } -py::object call_kw_func(py::function f) { - py::tuple args = py::make_tuple(1234); - py::dict kwargs; - kwargs["y"] = py::cast(5678); - return f(*args, **kwargs); -} - py::tuple args_function(py::args args) { return args; } @@ -49,9 +42,7 @@ test_initializer arg_keywords_and_defaults([](py::module &m) { std::vector list; list.push_back(13); list.push_back(17); - m.def("kw_func4", &kw_func4, py::arg("myList") = list); - m.def("call_kw_func", &call_kw_func); m.def("args_function", &args_function); m.def("args_kwargs_function", &args_kwargs_function); diff --git a/tests/test_kwargs_and_defaults.py b/tests/test_kwargs_and_defaults.py index 14d9c5ab8..0e1ea805e 100644 --- a/tests/test_kwargs_and_defaults.py +++ b/tests/test_kwargs_and_defaults.py @@ -1,7 +1,6 @@ import pytest -from pybind11_tests import (kw_func0, kw_func1, kw_func2, kw_func3, kw_func4, call_kw_func, - args_function, args_kwargs_function, kw_func_udl, kw_func_udl_z, - KWClass) +from pybind11_tests import (kw_func0, kw_func1, kw_func2, kw_func3, kw_func4, args_function, + args_kwargs_function, kw_func_udl, kw_func_udl_z, KWClass) def test_function_signatures(doc): @@ -49,8 +48,6 @@ def test_named_arguments(msg): def test_arg_and_kwargs(): - assert call_kw_func(kw_func2) == "x=1234, y=5678" - args = 'arg1_value', 'arg2_value', 3 assert args_function(*args) == args