diff --git a/include/boost/python/raw_function.hpp b/include/boost/python/raw_function.hpp index db861e12..1ed3c3c1 100755 --- a/include/boost/python/raw_function.hpp +++ b/include/boost/python/raw_function.hpp @@ -29,7 +29,10 @@ namespace detail { return incref( object( - f(tuple(borrowed_reference(args)), dict(borrowed_reference(keywords))) + f( + tuple(borrowed_reference(args)) + , keywords ? dict(borrowed_reference(keywords)) : dict() + ) ).ptr() ); } diff --git a/test/args.cpp b/test/args.cpp index a65933cb..c494b9d7 100644 --- a/test/args.cpp +++ b/test/args.cpp @@ -90,3 +90,5 @@ BOOST_PYTHON_MODULE(args_ext) def("inner", &X::inner, "docstring", args("self", "n"), return_internal_reference<>()); } + +#include "module_tail.cpp" diff --git a/test/args.py b/test/args.py index 2c9218b1..5bc749b3 100644 --- a/test/args.py +++ b/test/args.py @@ -4,6 +4,14 @@ >>> raw(3, 4, foo = 'bar', baz = 42) ((3, 4), {'foo': 'bar', 'baz': 42}) + Prove that we can handle empty keywords and non-keywords + +>>> raw(3, 4) +((3, 4), {}) + +>>> raw(foo = 'bar') +((), {'foo': 'bar'}) + >>> f(x= 1, y = 3, z = 'hello') (1, 3.0, 'hello')