diff --git a/Examples/test-suite/python/operator_overload_runme.py b/Examples/test-suite/python/operator_overload_runme.py index 2a2a69f52..f37e324cd 100644 --- a/Examples/test-suite/python/operator_overload_runme.py +++ b/Examples/test-suite/python/operator_overload_runme.py @@ -3,7 +3,7 @@ from operator_overload import * # first check all the operators are implemented correctly from pure C++ code Op_sanity_check() -pop = Op(6)/Op(3) # breaks in Python3 with or without -builtin +pop = Op(6)/Op(3) # test routine: a=Op() @@ -40,7 +40,7 @@ if not b>=d: e=Op(3) e+=d if not e==b: - raise RuntimeError("e==b (%s==%s)" % (str(e), str(b))) + raise RuntimeError("e==b (%s==%s)" % (e.i, b.i)) e-=c if not e==a: raise RuntimeError("e==a") @@ -75,12 +75,6 @@ if not -a==a: if not -b==Op(-5): raise RuntimeError("-b==Op(-5)") -# plus add some code to check the __str__ fn -if not str(Op(1))=='Op(1)': - raise RuntimeError("str(Op(1))=='Op(1)'") -if not str(Op(-3))=='Op(-3)': - raise RuntimeError("str(Op(-3))=='Op(-3)'") - """ /* Sample test code in C++ diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index ecbe7834e..996ee5a38 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -103,7 +103,7 @@ %pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative); %pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative); %pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply); -%pybinoperator(__div__, *::operator/, binaryfunc, nb_div); +%pybinoperator(__div__, *::operator/, binaryfunc, nb_divide); %pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder); %pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift); %pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift); @@ -117,8 +117,6 @@ %pycompare(__eq__, *::operator==, Py_EQ); %pycompare(__ne__, *::operator!=, Py_NE); -%feature("python:slot", "nb_truediv", functype="binaryfunc") *::operator/; - /* Special cases */ %rename(__invert__) *::operator~; %feature("python:slot", "nb_invert", functype="unaryfunc") *::operator~; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 039623e62..055d5a89c 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3716,9 +3716,9 @@ public: printSlot(f, getSlot(n, "feature:python:nb_inplace_xor"), "nb_inplace_xor", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_or"), "nb_inplace_or", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_floor_divide"), "nb_floor_divide", "binaryfunc"); - printSlot(f, getSlot(n, "feature:python:nb_true_divide"), "nb_true_divide", "binaryfunc"); + printSlot(f, getSlot(n, "feature:python:nb_divide"), "nb_true_divide", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_floor_divide"), "nb_inplace_floor_divide", "binaryfunc"); - printSlot(f, getSlot(n, "feature:python:nb_inplace_true_divide"), "nb_inplace_true_divide", "binaryfunc"); + printSlot(f, getSlot(n, "feature:python:nb_inplace_divide"), "nb_inplace_true_divide", "binaryfunc"); Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_index"), "nb_index", "unaryfunc"); Printv(f, "#endif\n", NIL);