Ticket #3356: patch

File patch, 893 bytes (added by Stefan Seefeld, 13 years ago)
  • boost/python/object_operators.hpp

     
    6060object_operators<U>::operator bool_type() const
    6161{
    6262    object_cref2 x = *static_cast<U const*>(this);
    63     return PyObject_IsTrue(x.ptr()) ? &object::ptr : 0;
     63    int res = PyObject_IsTrue(x.ptr());
     64    if (res < 0) throw error_already_set();
     65    else return res ? &object::ptr : 0;
    6466}
    6567
    6668template <class U>
     
    6870object_operators<U>::operator!() const
    6971{
    7072    object_cref2 x = *static_cast<U const*>(this);
    71     return !PyObject_IsTrue(x.ptr());
     73    int res = PyObject_IsTrue(x.ptr());
     74    if (res < 0) throw error_already_set();
     75    else return res == 1;
    7276}
    7377
    7478# define BOOST_PYTHON_COMPARE_OP(op, opid)                              \