Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r59356:1fd792086d89
Date: 2012-12-06 18:47 -0800
http://bitbucket.org/pypy/pypy/changeset/1fd792086d89/

Log:    hopefully fix round w/ ndigits=None

diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -97,7 +97,6 @@
 
 # ____________________________________________________________
 
-@unwrap_spec(w_ndigits=WrappedDefault(None))
 def round(space, w_number, w_ndigits=None):
     """round(number[, ndigits]) -> number
 
@@ -109,7 +108,7 @@
         raise operationerrfmt(space.w_TypeError,
                               "type %s doesn't define __round__ method",
                               space.type(w_number).getname(space))
-    if space.is_none(w_ndigits):
+    if w_ndigits is None:
         return space.get_and_call_function(round, w_number)
     else:
         return space.get_and_call_function(round, w_number, w_ndigits)
diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -730,6 +730,8 @@
         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):
diff --git a/pypy/objspace/std/longtype.py b/pypy/objspace/std/longtype.py
--- a/pypy/objspace/std/longtype.py
+++ b/pypy/objspace/std/longtype.py
@@ -160,7 +160,6 @@
            return q, r
 ''', filename=__file__).interphook('divmod_near')
 
-@unwrap_spec(w_ndigits=WrappedDefault(None))
 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:
@@ -180,7 +179,7 @@
     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:
         return space.int(w_long)
 
     ndigits = space.bigint_w(space.index(w_ndigits))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to