[pypy-svn] pypy improve-unwrap_spec: simpler unwrap_specs in array module

amauryfa commits-noreply at bitbucket.org
Wed Feb 16 19:19:46 CET 2011

Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: improve-unwrap_spec
Changeset: r42071:3876f4ed51f3
Date: 2011-02-16 16:35 +0100

Log:	simpler unwrap_specs in array module

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -3,25 +3,20 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.typedef import TypeDef, GetSetProperty, make_weakref_descr
 from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.interpreter.gateway import interp2app, ObjSpace, W_Root, \
-     ApplevelClass
-from pypy.rlib.jit import dont_look_inside
-from pypy.rlib import rgc
+from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rlib.rarithmetic import ovfcheck
-from pypy.rlib.rstruct.runpack import runpack
-from pypy.interpreter.argument import Arguments, Signature
-from pypy.interpreter.baseobjspace import ObjSpace, W_Root, Wrappable
+from pypy.interpreter.baseobjspace import Wrappable
 from pypy.objspace.std.stdtypedef import SMM, StdTypeDef
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.model import W_Object
-from pypy.interpreter.argument import Arguments, Signature
 from pypy.module._file.interp_file import W_File
 from pypy.interpreter.buffer import RWBuffer
 from pypy.objspace.std.multimethod import FailedToImplement
-def w_array(space, w_cls, typecode, w_args=None):
-    if len(w_args.arguments_w) > 1:
+ at unwrap_spec(typecode=str)
+def w_array(space, w_cls, typecode, __args__):
+    if len(__args__.arguments_w) > 1:
         msg = 'array() takes at most 2 arguments'
         raise OperationError(space.w_TypeError, space.wrap(msg))
     if len(typecode) != 1:
@@ -30,7 +25,7 @@
     typecode = typecode[0]
     if space.is_w(w_cls, space.gettypeobject(W_ArrayBase.typedef)):
-        if w_args.keywords: # XXX this might be forbidden fishing
+        if __args__.keywords:
             msg = 'array.array() does not take keyword arguments'
             raise OperationError(space.w_TypeError, space.wrap(msg))
@@ -39,8 +34,8 @@
             a = space.allocate_instance(types[tc].w_class, w_cls)
-            if len(w_args.arguments_w) > 0:
-                w_initializer = w_args.arguments_w[0]
+            if len(__args__.arguments_w) > 0:
+                w_initializer = __args__.arguments_w[0]
                 if space.type(w_initializer) is space.w_str:
                 elif space.type(w_initializer) is space.w_unicode:
@@ -55,7 +50,6 @@
         raise OperationError(space.w_ValueError, space.wrap(msg))
     return a
-w_array.unwrap_spec = (ObjSpace, W_Root, str, Arguments)
 array_append = SMM('append', 2)

More information about the Pypy-commit mailing list