id summary reporter owner description type status milestone component version severity resolution keywords cc 3710 error incorrect when calling boost::python function via functools.partial anonymous troy d. straszheim "Neal Becker wrote: > Has anyone noticed that a function created with boost::python using > args() to give keyword arguments doesn't seem to work with functools.partial keyword arguments (but does with positional args)? > > For example, I have this function: > class_ > (""uniform_real"", ""Uniform float distribution"", bp::init( > (bp::arg (""rng""), > bp::arg (""min""), > bp::arg (""max""))... > > Then: > from functools import partial > f = partial (uniform_real, rng=rng1) << using keyword doesn't work > f (1,2) > ArgumentError: Python argument types in > uniform_real.__init__(uniform_real, int, int) > did not match C++ signature: > __init__(_object*, boost::random::mersenne_twister {lvalue} rng, double min, double max) > > But this works: > from functools import partial > f = partial (uniform_real, rng1) << pos arg does work > > In [27]: f(1,2) > Out[27]: uniform_real(1,2) > That doesn't work for pure python functions either: >>> def f(x,y,z): return x*100 + y*10 + z ... >>> from functools import partial as p >>> p(f,x=1)(2,3) Traceback (most recent call last): File """", line 1, in TypeError: f() got multiple values for keyword argument 'x' >>> p(f,x=1)(y=2,z=3) 123 >>> p(f,1)(2,3) 123 The error message is misleading for sure. Boost.python is going through a list of overloads and trying them in order; if it runs out of overloads, it says nothing matched." Bugs new Boost 1.42.0 python USE GITHUB Boost 1.41.0 Problem