Philip Jenvey  committed 1fd7920

hopefully fix round w/ ndigits=None

  • Participants
  • Parent commits b4ea8cb
  • Branches py3k

Comments (0)

Files changed (3)

File pypy/module/__builtin__/

 # ____________________________________________________________
 def round(space, w_number, w_ndigits=None):
     """round(number[, ndigits]) -> number
         raise operationerrfmt(space.w_TypeError,
                               "type %s doesn't define __round__ method",
-    if space.is_none(w_ndigits):
+    if w_ndigits is None:
         return space.get_and_call_function(round, w_number)
         return space.get_and_call_function(round, w_number, w_ndigits)

File pypy/module/__builtin__/test/

         raises(TypeError, round, t)
         raises(TypeError, round, t, 0)
+        raises(TypeError, round, 3, None)
     def test_vars_obscure_case(self):
         class C_get_vars(object):
             def getDict(self):

File pypy/objspace/std/

            return q, r
 ''', filename=__file__).interphook('divmod_near')
 def descr___round__(space, w_long, w_ndigits=None):
     """To round an integer m to the nearest 10**n (n positive), we make
     use of the divmod_near operation, defined by:
     from pypy.objspace.std.longobject import W_AbstractIntObject, newlong
     assert isinstance(w_long, W_AbstractIntObject)
-    if space.is_none(w_ndigits):
+    if w_ndigits is None:
     ndigits = space.bigint_w(space.index(w_ndigits))