Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55708 - trunk/boost/python
From: rwgk_at_[hidden]
Date: 2009-08-21 20:18:29


Author: rwgk
Date: 2009-08-21 20:18:28 EDT (Fri, 21 Aug 2009)
New Revision: 55708
URL: http://svn.boost.org/trac/boost/changeset/55708

Log:
boost/python/object_operators.hpp: added missing error checks in operator bool_type(), operator!(); this resolves https://svn.boost.org/trac/boost/ticket/3356 posted by Stefan Seefeld
Text files modified:
   trunk/boost/python/object_operators.hpp | 8 ++++++--
   1 files changed, 6 insertions(+), 2 deletions(-)

Modified: trunk/boost/python/object_operators.hpp
==============================================================================
--- trunk/boost/python/object_operators.hpp (original)
+++ trunk/boost/python/object_operators.hpp 2009-08-21 20:18:28 EDT (Fri, 21 Aug 2009)
@@ -60,7 +60,9 @@
 object_operators<U>::operator bool_type() const
 {
     object_cref2 x = *static_cast<U const*>(this);
- return PyObject_IsTrue(x.ptr()) ? &object::ptr : 0;
+ int is_true = PyObject_IsTrue(x.ptr());
+ if (is_true < 0) throw_error_already_set();
+ return is_true ? &object::ptr : 0;
 }
 
 template <class U>
@@ -68,7 +70,9 @@
 object_operators<U>::operator!() const
 {
     object_cref2 x = *static_cast<U const*>(this);
- return !PyObject_IsTrue(x.ptr());
+ int is_true = PyObject_IsTrue(x.ptr());
+ if (is_true < 0) throw_error_already_set();
+ return !is_true;
 }
 
 # define BOOST_PYTHON_COMPARE_OP(op, opid) \


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