diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index 996ee5a38..588512fd0 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -103,7 +103,11 @@ %pybinoperator(__neg__, *::operator-(), unaryfunc, nb_negative); %pybinoperator(__neg__, *::operator-() const, unaryfunc, nb_negative); %pybinoperator(__mul__, *::operator*, binaryfunc, nb_multiply); +#if defined(SWIGPYTHON_PY3) +%pybinoperator(__truediv__, *::operator/, binaryfunc, nb_divide); +#else %pybinoperator(__div__, *::operator/, binaryfunc, nb_divide); +#endif %pybinoperator(__mod__, *::operator%, binaryfunc, nb_remainder); %pybinoperator(__lshift__, *::operator<<, binaryfunc, nb_lshift); %pybinoperator(__rshift__, *::operator>>, binaryfunc, nb_rshift); @@ -192,7 +196,11 @@ __bool__ = __nonzero__ %pyinplaceoper(__iadd__ , *::operator +=, binaryfunc, nb_inplace_add); %pyinplaceoper(__isub__ , *::operator -=, binaryfunc, nb_inplace_subtract); %pyinplaceoper(__imul__ , *::operator *=, binaryfunc, nb_inplace_multiply); +#if defined(SWIGPYTHON_PY3) +%pyinplaceoper(__itruediv__ , *::operator /=, binaryfunc, nb_inplace_divide); +#else %pyinplaceoper(__idiv__ , *::operator /=, binaryfunc, nb_inplace_divide); +#endif %pyinplaceoper(__imod__ , *::operator %=, binaryfunc, nb_inplace_remainder); %pyinplaceoper(__iand__ , *::operator &=, binaryfunc, nb_inplace_and); %pyinplaceoper(__ior__ , *::operator |=, binaryfunc, nb_inplace_or); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 055d5a89c..6d2edabe8 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -517,6 +517,7 @@ public: fputs(usage3, stdout); } else if (strcmp(argv[i], "-py3") == 0) { py3 = 1; + Preprocessor_define("SWIGPYTHON_PY3", 0); Swig_mark_arg(i); } else if (strcmp(argv[i], "-builtin") == 0) { builtin = 1;