[C++-sig] Re: boolean patch for builtin_converters.hpp

Daniel Holth dholth at fastmail.fm
Sun Jan 18 20:28:08 CET 2004


On Sun, 2004-01-18 at 10:39, David Abrahams wrote:
> Daniel Holth <dholth at fastmail.fm> writes:
> 
> > Here's something for fans of Python's relatively new True and False
> > objects.

> > diff -r1.22 builtin_converters.hpp
> > 95c95
> > < BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, ::PyInt_FromLong(x))
> > ---
> >> BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, ::PyBool_FromLong(x))
> 
> This patch will break 2.2 compatibility and possibly some of the
> Boost.Python regression tests if we take it as-is.
> 
> Please try again, though; I'd like to accept a patch for this!

Not too hard, this version will use the new behavior only in Pythons 2.3
and above:

// Bool is not signed.
#if PY_VERSION_HEX >= 0x02030000
BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, ::PyBool_FromLong(x))
#else
BOOST_PYTHON_TO_PYTHON_BY_VALUE(bool, ::PyInt_FromLong(x))
#endif

- dwh





More information about the Cplusplus-sig mailing list