Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52299 - trunk/libs/python/src/converter
From: rwgk_at_[hidden]
Date: 2009-04-09 13:30:13


Author: rwgk
Date: 2009-04-09 13:30:13 EDT (Thu, 09 Apr 2009)
New Revision: 52299
URL: http://svn.boost.org/trac/boost/changeset/52299

Log:
libs/python/src/converter/builtin_converters.cpp: Troy Straszheim's bool/int patch with additional BOOST_PYTHON_BOOL_INT_STRICT condition; see also: http://mail.python.org/pipermail/cplusplus-sig/2009-March/014354.html
Text files modified:
   trunk/libs/python/src/converter/builtin_converters.cpp | 19 ++++++++++++++++---
   1 files changed, 16 insertions(+), 3 deletions(-)

Modified: trunk/libs/python/src/converter/builtin_converters.cpp
==============================================================================
--- trunk/libs/python/src/converter/builtin_converters.cpp (original)
+++ trunk/libs/python/src/converter/builtin_converters.cpp 2009-04-09 13:30:13 EDT (Thu, 09 Apr 2009)
@@ -99,8 +99,13 @@
           if (number_methods == 0)
               return 0;
 
- return (PyInt_Check(obj) || PyLong_Check(obj))
- ? &number_methods->nb_int : 0;
+ return (
+#if PY_VERSION_HEX >= 0x02040000 && defined(BOOST_PYTHON_BOOL_INT_STRICT)
+ !PyBool_Check(obj) &&
+#endif
+ (PyInt_Check(obj) || PyLong_Check(obj)))
+
+ ? &number_methods->nb_int : 0;
       }
       static PyTypeObject const* get_pytype() { return &PyInt_Type;}
   };
@@ -135,7 +140,11 @@
           if (number_methods == 0)
               return 0;
 
- return (PyInt_Check(obj) || PyLong_Check(obj))
+ return (
+#if PY_VERSION_HEX >= 0x02040000 && defined(BOOST_PYTHON_BOOL_INT_STRICT)
+ !PyBool_Check(obj) &&
+#endif
+ (PyInt_Check(obj) || PyLong_Check(obj)))
               ? &py_object_identity : 0;
       }
       static PyTypeObject const* get_pytype() { return &PyInt_Type;}
@@ -226,7 +235,11 @@
   {
       static unaryfunc* get_slot(PyObject* obj)
       {
+#if PY_VERSION_HEX >= 0x02040000 && defined(BOOST_PYTHON_BOOL_INT_STRICT)
+ return obj == Py_None || PyBool_Check(obj) ? &py_object_identity : 0;
+#else
           return obj == Py_None || PyInt_Check(obj) ? &py_object_identity : 0;
+#endif
       }
       
       static bool extract(PyObject* intermediate)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk