[C++-sig] boost.python: no overflow checking for unsigned int parameters ?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Mon Jun 15 22:23:57 CEST 2009


If you send me a patch (against the boost trunk) I'll test it and check it in.
Probably, the file to be changed is
  boost/libs/python/src/converter/builtin_converters.cpp
I'd try working with
  boost/numeric/conversion/cast.hpp
Ralf



----- Original Message ----

From: Anderson Lizardo <anderson.lizardo at openbossa.org>
To: cplusplus-sig at python.org
Sent: Monday, June 15, 2009 12:24:29 PM
Subject: [C++-sig] boost.python: no overflow checking for unsigned int parameters ?

Hi,

I noticed that boost.python silently accepts negative (or too long)
integers for constructor/methods that have "unsigned int" parameters.
(signed) "int" arguments seem to be handled just fine. Is it possible
to tell boost.python to check for overflow and raise an exception just
like it happens to int parameters ?

BTW, I'm using boost1.38.

See test case below (save it as "mymodule.cpp"), "MyClass1" uses int
parameters, "MyClass2" uses unsigned int:

### snip ###



More information about the Cplusplus-sig mailing list