Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
make this more in line with my principle of minimal code in a try/except
- Loading branch information
Showing
with
4 additions
and
2 deletions.
-
+4
−2
topaz/objects/intobject.py
|
@@ -145,17 +145,19 @@ def method_div(self, space, w_other): |
|
|
@classdef.method("fdiv") |
|
|
def method_fdiv(self, space, w_other): |
|
|
if space.is_kind_of(w_other, space.w_fixnum): |
|
|
other = space.int_w(w_other) |
|
|
try: |
|
|
res = float(self.intvalue) / float(space.int_w(w_other)) |
|
|
res = float(self.intvalue) / float(other) |
|
|
except ZeroDivisionError: |
|
|
return space.newfloat(rfloat.copysign(rfloat.INFINITY, float(self.intvalue))) |
|
|
else: |
|
|
return space.newfloat(res) |
|
|
elif space.is_kind_of(w_other, space.w_bignum): |
|
|
return space.send(space.newbigint_fromint(self.intvalue), "fdiv", [w_other]) |
|
|
elif space.is_kind_of(w_other, space.w_float): |
|
|
other = space.float_w(w_other) |
|
|
try: |
|
|
res = float(self.intvalue) / space.float_w(w_other) |
|
|
res = float(self.intvalue) / other |
|
|
except ZeroDivisionError: |
|
|
return space.newfloat(rfloat.copysign(rfloat.INFINITY, float(self.intvalue))) |
|
|
else: |
|
|