[Boost-bugs] [Boost C++ Libraries] #4726: Bugs when using named args.

Subject: [Boost-bugs] [Boost C++ Libraries] #4726: Bugs when using named args.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-10-11 11:39:51


#4726: Bugs when using named args.
----------------------------------------------+-----------------------------
 Reporter: Albin Thoren <thorena@…> | Owner: dave
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: Python
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
----------------------------------------------+-----------------------------
 There seem to be issues when naming function arguments. Same thing happens
 for class_ defs and init<> functions.

 Using non-named args {{{f(1,2,3)}}} works fine in all cases below but
 using named args {{{f(1,2,z=3)}}} works or fails depending on boost python
 definition.

 The first two of the following defs fail when using named args. The first
 one crashes python and the second raises "did not match C++ signature"
 exception. The third version works as expected.
 {{{#!cpp
 #include <boost/python/module.hpp>
 #include <boost/python/def.hpp>

 int f(int x, int y, int z) { return x*y*z;}

 BOOST_PYTHON_MODULE(_pylib)
 {
         namespace bp = boost::python;
         // Bug
         bp::def("bug1", &f, ("x", "y", bp::arg("z")));
         bp::def("bug2", &f, ("x", "y", "z"));
         // Works
         bp::def("works_fine", &f, (bp::arg("x"), bp::arg("y"),
 bp::arg("z")));
 }
 }}}

 Running {{{ bug1(x=1, y=2, z=3) }}} crashes python and {{{bug2(1, 2,
 z=3)}}} gives an {{{ArgumentError}}}
 {{{
 Boost.Python.ArgumentError: Python argument types in
     _pylib.bug2(int, int)
 did not match C++ signature:
     bug2(int, int, int)
 }}}

 Summary of errors:
 {{{#!python
 from _pylib import *

 works_fine(1,2,3) # OK
 bug1(1,2,3) # OK
 bug2(1,2,3) # OK

 works_fine(1, 2, z=3) # OK
 bug1(1, 2, z=3) # OK
 bug2(1, 2, z=3) # Error: did not match C++ signature


 works_fine(x=1, y=2, z=3) # OK
 bug1(x=1, y=2, z=3) # Error: Python crashes and exits abnormally
 bug2(x=1, y=2, z=3) # Error: did not match C++ signature
 }}}


 I'm using:
 * boost 1.44. {{{BoostPro}}} Windows pre-built binary for VC++ 2008.
 * Python 2.6
   * {{{sys.version = '2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC
 v.1500 32 bit (Intel)]')}}}
 * Microsoft VC++ 2008

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4726>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC