2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-21 17:12:22 +00:00

Make object comparison operators return object instead of bool, to

accomodate strange beasts like numarray arrays that return arrays that
can't be used as truth values from their comparison ops.

Fix numpy test for portability with old doctest (again!)


[SVN r35572]
This commit is contained in:
Dave Abrahams
2006-10-12 09:07:07 +00:00
parent 1755dad7e6
commit d61909d3ea
3 changed files with 32 additions and 14 deletions

View File

@@ -8,6 +8,24 @@
namespace boost { namespace python { namespace api {
# define BOOST_PYTHON_COMPARE_OP(op, opid) \
BOOST_PYTHON_DECL object operator op(object const& l, object const& r) \
{ \
return object( \
detail::new_reference( \
PyObject_RichCompare( \
l.ptr(), r.ptr(), opid)) \
); \
}
BOOST_PYTHON_COMPARE_OP(>, Py_GT)
BOOST_PYTHON_COMPARE_OP(>=, Py_GE)
BOOST_PYTHON_COMPARE_OP(<, Py_LT)
BOOST_PYTHON_COMPARE_OP(<=, Py_LE)
BOOST_PYTHON_COMPARE_OP(==, Py_EQ)
BOOST_PYTHON_COMPARE_OP(!=, Py_NE)
# undef BOOST_PYTHON_COMPARE_OP
#define BOOST_PYTHON_BINARY_OPERATOR(op, name) \
BOOST_PYTHON_DECL object operator op(object const& l, object const& r) \
{ \