Author: stian
Branch: math-improvements
Changeset: r92793:b4e5817c17d8
Date: 2017-10-18 22:14 +0200
http://bitbucket.org/pypy/pypy/changeset/b4e5817c17d8/
Log: Missing from earlier
diff --git a/pypy/objspace/std/longobject.py b/pypy/objspace/std/longobject.py
--- a/pypy/objspace/std/longobject.py
+++ b/pypy/objspace/std/longobject.py
@@ -491,17 +491,18 @@
"long division or modulo by zero")
return newlong(space, z)
- def _floordiv(self, space, w_other):
+ def _int_floordiv(self, space, w_other):
try:
- z = self.num.floordiv(w_other.asbigint())
+ z = self.num.int_floordiv(w_other)
except ZeroDivisionError:
raise oefmt(space.w_ZeroDivisionError,
"long division or modulo by zero")
return newlong(space, z)
- descr_floordiv, descr_rfloordiv = _make_descr_binop(_floordiv)
+ descr_floordiv, descr_rfloordiv = _make_descr_binop(_floordiv,
_int_floordiv)
_div = func_with_new_name(_floordiv, '_div')
- descr_div, descr_rdiv = _make_descr_binop(_div)
+ _int_div = func_with_new_name(_int_floordiv, '_int_div')
+ descr_div, descr_rdiv = _make_descr_binop(_div, _int_div)
def _mod(self, space, w_other):
try:
@@ -527,7 +528,16 @@
raise oefmt(space.w_ZeroDivisionError,
"long division or modulo by zero")
return space.newtuple([newlong(space, div), newlong(space, mod)])
- descr_divmod, descr_rdivmod = _make_descr_binop(_divmod)
+
+ def _int_divmod(self, space, w_other):
+ try:
+ div, mod = self.num.int_divmod(w_other)
+ except ZeroDivisionError:
+ raise oefmt(space.w_ZeroDivisionError,
+ "long division or modulo by zero")
+ return space.newtuple([newlong(space, div), newlong(space, mod)])
+
+ descr_divmod, descr_rdivmod = _make_descr_binop(_divmod, _int_divmod)
def newlong(space, bigint):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit