[pypy-svn] pypy improve-unwrap_spec: modern unwrap_spec in imp module

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


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: improve-unwrap_spec
Changeset: r42075:866835341f94
Date: 2011-02-16 17:00 +0100
http://bitbucket.org/pypy/pypy/changeset/866835341f94/

Log:	modern unwrap_spec in imp module

diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -3,7 +3,7 @@
 from pypy.rlib import streamio
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.module import Module
-from pypy.interpreter.gateway import NoneNotWrapped, W_Root, ObjSpace
+from pypy.interpreter.gateway import NoneNotWrapped, unwrap_spec
 from pypy.module._file.interp_stream import StreamErrors, wrap_streamerror
 import struct
 
@@ -105,6 +105,7 @@
         stream.close()
     return w_mod
 
+ at unwrap_spec(filename=str)
 def _run_compiled_module(space, w_modulename, filename, w_file, w_module):
     # the function 'imp._run_compiled_module' is a pypy-only extension
     stream = get_file(space, w_file, filename, 'rb')
@@ -117,14 +118,13 @@
         stream.readall())
     if space.is_w(w_file, space.w_None):
         stream.close()
-_run_compiled_module.unwrap_spec = [ObjSpace, W_Root, str, W_Root, W_Root]
 
+ at unwrap_spec(filename=str)
 def load_compiled(space, w_modulename, filename, w_file=None):
     w_mod = space.wrap(Module(space, w_modulename))
     importing._prepare_module(space, w_mod, filename, None)
     _run_compiled_module(space, w_modulename, filename, w_file, w_mod)
     return w_mod
-load_compiled.unwrap_spec = [ObjSpace, W_Root, str, W_Root]
 
 def new_module(space, w_name):
     return space.wrap(Module(space, w_name))

diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -5,10 +5,10 @@
 import sys, os, stat
 
 from pypy.interpreter.module import Module
-from pypy.interpreter.gateway import Arguments, interp2app, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import TypeDef, generic_new_descr
 from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.baseobjspace import W_Root, ObjSpace, Wrappable
+from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.eval import Code
 from pypy.rlib import streamio, jit, rposix
 from pypy.rlib.streamio import StreamErrors
@@ -108,6 +108,7 @@
 def check_sys_modules_w(space, modulename):
     return space.finditem_str(space.sys.get('modules'), modulename)
 
+ at unwrap_spec(name=str, level=int)
 def importhook(space, name, w_globals=None,
                w_locals=None, w_fromlist=None, level=-1):
     modulename = name
@@ -186,8 +187,6 @@
         space.setitem(space.sys.get('modules'), w(rel_modulename), space.w_None)
     space.timer.stop_name("importhook", modulename)
     return w_mod
-#
-importhook.unwrap_spec = [ObjSpace, str, W_Root, W_Root, W_Root, int]
 
 @jit.dont_look_inside
 def absolute_import(space, modulename, baselevel, fromlist_w, tentative):
@@ -330,7 +329,7 @@
     def __init__(self, space):
         pass
 
-    @unwrap_spec('self', ObjSpace, str)
+    @unwrap_spec(path=str)
     def descr_init(self, space, path):
         if not path:
             raise OperationError(space.w_ImportError, space.wrap(
@@ -346,7 +345,6 @@
                 raise OperationError(space.w_ImportError, space.wrap(
                     "existing directory"))
 
-    @unwrap_spec('self', ObjSpace, Arguments)
     def find_module_w(self, space, __args__):
         return space.wrap(None)
 


More information about the Pypy-commit mailing list