Skip to content
Permalink
Browse files

make this more in line with my principle of minimal code in a try/except

  • Loading branch information
alex committed Jun 18, 2013
1 parent e44170b commit dba61bac911a67103ea447b3d2f3bae8372d5d55
Showing with 4 additions and 2 deletions.
  1. +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:

0 comments on commit dba61ba

Please sign in to comment.
You can’t perform that action at this time.