[pypy-svn] pypy improve-unwrap_spec: newer unwrap_spec in modules thread, time, token
amauryfa
commits-noreply at bitbucket.org
Wed Feb 16 19:20:23 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: improve-unwrap_spec
Changeset: r42085:cfb157c1cfd7
Date: 2011-02-16 18:40 +0100
http://bitbucket.org/pypy/pypy/changeset/cfb157c1cfd7/
Log: newer unwrap_spec in modules thread, time, token
diff --git a/pypy/module/thread/os_local.py b/pypy/module/thread/os_local.py
--- a/pypy/module/thread/os_local.py
+++ b/pypy/module/thread/os_local.py
@@ -4,7 +4,6 @@
from pypy.interpreter.typedef import TypeDef, interp2app
from pypy.interpreter.typedef import GetSetProperty, descr_get_dict
from pypy.interpreter.typedef import descr_set_dict
-from pypy.interpreter.gateway import ObjSpace, W_Root, Arguments
class Local(Wrappable):
@@ -42,12 +41,10 @@
local = space.allocate_instance(Local, w_subtype)
Local.__init__(local, space, __args__)
return space.wrap(local)
- descr_local__new__.unwrap_spec=[ObjSpace, W_Root, Arguments]
def descr_local__init__(self, space):
# No arguments allowed
pass
- descr_local__init__.unwrap_spec=['self', ObjSpace]
Local.typedef = TypeDef("thread._local",
__doc__ = "Thread-local data",
diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py
--- a/pypy/module/time/interp_time.py
+++ b/pypy/module/time/interp_time.py
@@ -1,5 +1,5 @@
import time
-from pypy.interpreter.gateway import ObjSpace
+from pypy.interpreter.gateway import unwrap_spec
def clock(space):
@@ -13,8 +13,8 @@
second may be present if the system clock provides them."""
return space.wrap(time.time())
+ at unwrap_spec(seconds=float)
def sleep(space, seconds):
"""Delay execution for a given number of seconds. The argument may
be a floating point number for subsecond precision."""
time.sleep(seconds)
-sleep.unwrap_spec = [ObjSpace, float]
diff --git a/pypy/module/token/__init__.py b/pypy/module/token/__init__.py
--- a/pypy/module/token/__init__.py
+++ b/pypy/module/token/__init__.py
@@ -1,5 +1,5 @@
from pypy.interpreter.mixedmodule import MixedModule
-from pypy.interpreter.baseobjspace import ObjSpace
+from pypy.interpreter.gateway import unwrap_spec
from pypy.interpreter.pyparser import pytoken, pygram
@@ -25,14 +25,14 @@
_init_tokens()
+ at unwrap_spec(tok=int)
def isterminal(space, tok):
return space.wrap(tok < 256)
-isterminal.unwrap_spec = [ObjSpace, int]
+ at unwrap_spec(tok=int)
def isnonterminal(space, tok):
return space.wrap(tok >= 256)
-isnonterminal.unwrap_spec = [ObjSpace, int]
+ at unwrap_spec(tok=int)
def iseof(space, tok):
return space.wrap(tok == pygram.tokens.ENDMARKER)
-iseof.unwrap_spec = [ObjSpace, int]
diff --git a/pypy/module/thread/os_thread.py b/pypy/module/thread/os_thread.py
--- a/pypy/module/thread/os_thread.py
+++ b/pypy/module/thread/os_thread.py
@@ -5,8 +5,7 @@
from pypy.module.thread import ll_thread as thread
from pypy.module.thread.error import wrap_thread_error
from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.gateway import NoneNotWrapped
-from pypy.interpreter.gateway import ObjSpace, W_Root, Arguments
+from pypy.interpreter.gateway import unwrap_spec, NoneNotWrapped, Arguments
from pypy.rlib.objectmodel import free_non_gc_object
# Here are the steps performed to start a new thread:
@@ -202,6 +201,7 @@
ident = thread.get_ident()
return space.wrap(ident)
+ at unwrap_spec(size=int)
def stack_size(space, size=0):
"""stack_size([size]) -> size
@@ -232,7 +232,6 @@
if error == -2:
raise wrap_thread_error(space, "setting stack size not supported")
return space.wrap(old_size)
-stack_size.unwrap_spec = [ObjSpace, int]
def _count(space):
"""_count() -> integer
diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py
--- a/pypy/module/thread/os_lock.py
+++ b/pypy/module/thread/os_lock.py
@@ -5,7 +5,7 @@
from pypy.module.thread import ll_thread as thread
from pypy.module.thread.error import wrap_thread_error
from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.gateway import ObjSpace, interp2app, Arguments
+from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef
# Force the declaration of the type 'thread.LockType' for RPython
@@ -36,6 +36,7 @@
except thread.error:
raise wrap_thread_error(space, "out of resources")
+ @unwrap_spec(waitflag=int)
def descr_lock_acquire(self, space, waitflag=1):
"""Lock the lock. Without argument, this blocks if the lock is already
locked (even by the same thread), waiting for another thread to release
@@ -78,16 +79,11 @@
def __exit__(self, *args):
self.descr_lock_release(self.space)
-descr_acquire = interp2app(Lock.descr_lock_acquire,
- unwrap_spec=['self', ObjSpace, int])
-descr_release = interp2app(Lock.descr_lock_release,
- unwrap_spec=['self', ObjSpace])
-descr_locked = interp2app(Lock.descr_lock_locked,
- unwrap_spec=['self', ObjSpace])
-descr__enter__ = interp2app(Lock.descr__enter__,
- unwrap_spec=['self', ObjSpace])
-descr__exit__ = interp2app(Lock.descr__exit__,
- unwrap_spec=['self', ObjSpace, Arguments])
+descr_acquire = interp2app(Lock.descr_lock_acquire)
+descr_release = interp2app(Lock.descr_lock_release)
+descr_locked = interp2app(Lock.descr_lock_locked)
+descr__enter__ = interp2app(Lock.descr__enter__)
+descr__exit__ = interp2app(Lock.descr__exit__)
Lock.typedef = TypeDef("thread.lock",
More information about the Pypy-commit
mailing list