[Boost-bugs] [Boost C++ Libraries] #3189: Python integer/long conversion to C++ unsigned int/long is broken

Subject: [Boost-bugs] [Boost C++ Libraries] #3189: Python integer/long conversion to C++ unsigned int/long is broken
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-06-18 12:55:07


#3189: Python integer/long conversion to C++ unsigned int/long is broken
--------------------------------------------+-------------------------------
 Reporter: anderson.lizardo_at_[hidden] | Owner: dave
     Type: Patches | Status: new
Milestone: Boost 1.40.0 | Component: Python
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
--------------------------------------------+-------------------------------
 The following snippet in libs/python/src/converter/builtin_converters.cpp:

 {{{
           return numeric_cast<T>(
               PyLong_Check(intermediate)
               ? PyLong_AsUnsignedLong(intermediate)
               : PyInt_AS_LONG(intermediate));

 }}}

 does not check if an exception was thrown by the Python/C conversion
 functions. Therefore, in case of error, these functions are returning -1,
 which is being cast to unsigned int.

 Another missing check is when the Python integer value to be converted is
 negative. In this case, a proper exception (such as ValueError) must be
 thrown.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3189>
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:00 UTC