[pypy-svn] pypy improve-unwrap_spec: Small unwrap_spec simplifications in various places

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


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: improve-unwrap_spec
Changeset: r42089:ff6aa900d761
Date: 2011-02-16 19:04 +0100
http://bitbucket.org/pypy/pypy/changeset/ff6aa900d761/

Log:	Small unwrap_spec simplifications in various places

diff --git a/pypy/translator/goal/nanos.py b/pypy/translator/goal/nanos.py
--- a/pypy/translator/goal/nanos.py
+++ b/pypy/translator/goal/nanos.py
@@ -25,7 +25,7 @@
 more from os and os.path.
 """
 
-from pypy.interpreter.gateway import applevel, ObjSpace, W_Root, interp2app
+from pypy.interpreter.gateway import applevel, interp2app
 import os, py
 
 if os.name == 'posix':
@@ -268,7 +268,7 @@
 def getenv(space, w_name):
     name = space.str_w(w_name)
     return space.wrap(os.environ.get(name))
-getenv_w = interp2app(getenv, unwrap_spec=[ObjSpace, W_Root])
+getenv_w = interp2app(getenv)
 
 def setup_nanos(space):
     w_os = space.wrap(app_os.buildmodule(space, 'os'))

diff --git a/pypy/module/struct/interp_struct.py b/pypy/module/struct/interp_struct.py
--- a/pypy/module/struct/interp_struct.py
+++ b/pypy/module/struct/interp_struct.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.gateway import ObjSpace
+from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.error import OperationError
 from pypy.rlib.rstruct.error import StructError
 from pypy.module.struct.formatiterator import CalcSizeFormatIterator
@@ -6,6 +6,7 @@
 from pypy.module.struct.formatiterator import UnpackFormatIterator
 
 
+ at unwrap_spec(format=str)
 def calcsize(space, format):
     fmtiter = CalcSizeFormatIterator()
     try:
@@ -13,9 +14,9 @@
     except StructError, e:
         raise e.at_applevel(space)
     return space.wrap(fmtiter.totalsize)
-calcsize.unwrap_spec = [ObjSpace, str]
 
 
+ at unwrap_spec(format=str)
 def pack(space, format, args_w):
     fmtiter = PackFormatIterator(space, args_w)
     try:
@@ -24,9 +25,9 @@
         raise e.at_applevel(space)
     result = ''.join(fmtiter.result)
     return space.wrap(result)
-pack.unwrap_spec = [ObjSpace, str, 'args_w']
 
 
+ at unwrap_spec(format=str, input='bufferstr')
 def unpack(space, format, input):
     fmtiter = UnpackFormatIterator(space, input)
     try:
@@ -34,4 +35,3 @@
     except StructError, e:
         raise e.at_applevel(space)
     return space.newtuple(fmtiter.result_w[:])
-unpack.unwrap_spec = [ObjSpace, str, 'bufferstr']

diff --git a/pypy/module/crypt/interp_crypt.py b/pypy/module/crypt/interp_crypt.py
--- a/pypy/module/crypt/interp_crypt.py
+++ b/pypy/module/crypt/interp_crypt.py
@@ -1,5 +1,5 @@
 from pypy.interpreter.error import OperationError
-from pypy.interpreter.baseobjspace import ObjSpace, W_Root
+from pypy.interpreter.baseobjspace import unwrap_spec
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 import sys
@@ -11,6 +11,7 @@
 c_crypt = rffi.llexternal('crypt', [rffi.CCHARP, rffi.CCHARP], rffi.CCHARP,
                           compilation_info=eci, threadsafe=False)
 
+ at unwrap_spec(word=str, salt=str)
 def crypt(space, word, salt):
     """word will usually be a user's password. salt is a 2-character string
     which will be used to select one of 4096 variations of DES. The characters
@@ -22,5 +23,3 @@
         return space.w_None
     str_res = rffi.charp2str(res)
     return space.wrap(str_res) 
-
-crypt.unwrap_spec = [ObjSpace, str, str]

diff --git a/pypy/tool/pytest/appsupport.py b/pypy/tool/pytest/appsupport.py
--- a/pypy/tool/pytest/appsupport.py
+++ b/pypy/tool/pytest/appsupport.py
@@ -176,10 +176,7 @@
     w_BuiltinAssertionError = space.getitem(space.builtin.w_dict, 
                                             space.wrap('AssertionError'))
     w_metaclass = space.type(w_BuiltinAssertionError)
-    w_init = space.wrap(gateway.interp2app_temp(my_init,
-                                                unwrap_spec=[gateway.ObjSpace,
-                                                             gateway.W_Root,
-                                                             gateway.Arguments]))
+    w_init = space.wrap(gateway.interp2app_temp(my_init)
     w_dict = space.newdict()
     space.setitem(w_dict, space.wrap('__init__'), w_init)
     return space.call_function(w_metaclass,
@@ -247,11 +244,7 @@
     raise OperationError(space.w_AssertionError,
                          space.wrap("DID NOT RAISE"))
 
-app_raises = gateway.interp2app_temp(pypyraises,
-                                     unwrap_spec=[gateway.ObjSpace,
-                                                  gateway.W_Root,
-                                                  gateway.W_Root,
-                                                  gateway.Arguments])
+app_raises = gateway.interp2app_temp(pypyraises)
 
 def pypyskip(space, w_message): 
     """skip a test at app-level. """ 


More information about the Pypy-commit mailing list