Skip to content

Commit a3cdacd

Browse files
committed
Bug fix -- we weren't handling NULL keywords dictionaries in raw_function
[SVN r19359]
1 parent 81d99c8 commit a3cdacd

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

include/boost/python/raw_function.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ namespace detail
2929
{
3030
return incref(
3131
object(
32-
f(tuple(borrowed_reference(args)), dict(borrowed_reference(keywords)))
32+
f(
33+
tuple(borrowed_reference(args))
34+
, keywords ? dict(borrowed_reference(keywords)) : dict()
35+
)
3336
).ptr()
3437
);
3538
}

test/args.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,5 @@ BOOST_PYTHON_MODULE(args_ext)
9090

9191
def("inner", &X::inner, "docstring", args("self", "n"), return_internal_reference<>());
9292
}
93+
94+
#include "module_tail.cpp"

test/args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
>>> raw(3, 4, foo = 'bar', baz = 42)
55
((3, 4), {'foo': 'bar', 'baz': 42})
66
7+
Prove that we can handle empty keywords and non-keywords
8+
9+
>>> raw(3, 4)
10+
((3, 4), {})
11+
12+
>>> raw(foo = 'bar')
13+
((), {'foo': 'bar'})
14+
715
>>> f(x= 1, y = 3, z = 'hello')
816
(1, 3.0, 'hello')
917

0 commit comments

Comments
 (0)