[pypy-svn] pypy improve-unwrap_spec: Update unwrap_spec in _multiprocessing module

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


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: improve-unwrap_spec
Changeset: r42061:c9bd9c16dade
Date: 2011-02-16 13:03 +0100
http://bitbucket.org/pypy/pypy/changeset/c9bd9c16dade/

Log:	Update unwrap_spec in _multiprocessing module

diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py
--- a/pypy/module/_multiprocessing/interp_semaphore.py
+++ b/pypy/module/_multiprocessing/interp_semaphore.py
@@ -1,7 +1,7 @@
 from __future__ import with_statement
-from pypy.interpreter.baseobjspace import ObjSpace, Wrappable, W_Root
+from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
-from pypy.interpreter.gateway import interp2app, Arguments, unwrap_spec
+from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.error import wrap_oserror, OperationError
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.rlib.rarithmetic import r_uint
@@ -409,18 +409,15 @@
     def handle_get(space, self):
         return w_handle(space, self.handle)
 
-    @unwrap_spec('self', ObjSpace)
     def get_count(self, space):
         return space.wrap(self.count)
 
     def _ismine(self):
         return self.count > 0 and ll_thread.get_ident() == self.last_tid
 
-    @unwrap_spec('self', ObjSpace)
     def is_mine(self, space):
         return space.wrap(self._ismine())
 
-    @unwrap_spec('self', ObjSpace)
     def is_zero(self, space):
         try:
             res = semlock_iszero(self, space)
@@ -428,7 +425,6 @@
             raise wrap_oserror(space, e)
         return space.wrap(res)
 
-    @unwrap_spec('self', ObjSpace)
     def get_value(self, space):
         try:
             val = semlock_getvalue(self, space)
@@ -436,7 +432,7 @@
             raise wrap_oserror(space, e)
         return space.wrap(val)
 
-    @unwrap_spec('self', ObjSpace, bool, W_Root)
+    @unwrap_spec(block=bool)
     def acquire(self, space, block=True, w_timeout=None):
         # check whether we already own the lock
         if self.kind == RECURSIVE_MUTEX and self._ismine():
@@ -455,7 +451,6 @@
         else:
             return space.w_False
 
-    @unwrap_spec('self', ObjSpace)
     def release(self, space):
         if self.kind == RECURSIVE_MUTEX:
             if not self._ismine():
@@ -474,21 +469,19 @@
 
         self.count -= 1
 
-    @unwrap_spec(ObjSpace, W_Root, W_Root, int, int)
+    @unwrap_spec(kind=int, maxvalue=int)
     def rebuild(space, w_cls, w_handle, kind, maxvalue):
         self = space.allocate_instance(W_SemLock, w_cls)
         self.__init__(handle_w(space, w_handle), kind, maxvalue)
         return space.wrap(self)
 
-    @unwrap_spec('self', ObjSpace)
     def enter(self, space):
         return self.acquire(space, w_timeout=space.w_None)
 
-    @unwrap_spec('self', ObjSpace, Arguments)
     def exit(self, space, __args__):
         self.release(space)
 
- at unwrap_spec(ObjSpace, W_Root, int, int, int)
+ at unwrap_spec(kind=int, value=int, maxvalue=int)
 def descr_new(space, w_subtype, kind, value, maxvalue):
     if kind != RECURSIVE_MUTEX and kind != SEMAPHORE:
         raise OperationError(space.w_ValueError,

diff --git a/pypy/module/_multiprocessing/interp_connection.py b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -1,5 +1,5 @@
 from __future__ import with_statement
-from pypy.interpreter.baseobjspace import ObjSpace, Wrappable, W_Root
+from pypy.interpreter.baseobjspace import Wrappable
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.error import (
@@ -69,7 +69,7 @@
             raise OperationError(space.w_IOError,
                                  space.wrap("connection is read-only"))
 
-    @unwrap_spec('self', ObjSpace, 'bufferstr', 'index', 'index')
+    @unwrap_spec(buffer='bufferstr', offset='index', size='index')
     def send_bytes(self, space, buffer, offset=0, size=PY_SSIZE_T_MIN):
         length = len(buffer)
         self._check_writable(space)
@@ -91,7 +91,7 @@
 
         self.do_send_string(space, buffer, offset, size)
 
-    @unwrap_spec('self', ObjSpace, 'index')
+    @unwrap_spec(maxlength='index')
     def recv_bytes(self, space, maxlength=PY_SSIZE_T_MAX):
         self._check_readable(space)
         if maxlength < 0:
@@ -110,7 +110,7 @@
             if newbuf:
                 rffi.free_charp(newbuf)
 
-    @unwrap_spec('self', ObjSpace, W_Root, 'index')
+    @unwrap_spec(offset='index')
     def recv_bytes_into(self, space, w_buffer, offset=0):
         rwbuffer = space.rwbuffer_w(w_buffer)
         length = rwbuffer.getlength()
@@ -129,7 +129,6 @@
 
         return space.wrap(res)
 
-    @unwrap_spec('self', ObjSpace, W_Root)
     def send(self, space, w_obj):
         self._check_writable(space)
 
@@ -144,7 +143,6 @@
         buffer = space.bufferstr_w(w_pickled)
         self.do_send_string(space, buffer, 0, len(buffer))
 
-    @unwrap_spec('self', ObjSpace)
     def recv(self, space):
         self._check_readable(space)
 
@@ -168,7 +166,6 @@
 
         return w_unpickled
 
-    @unwrap_spec('self', ObjSpace, W_Root)
     def poll(self, space, w_timeout=0.0):
         self._check_readable(space)
         if space.is_w(w_timeout, space.w_None):
@@ -232,7 +229,7 @@
         W_BaseConnection.__init__(self, flags)
         self.fd = fd
 
-    @unwrap_spec(ObjSpace, W_Root, int, bool, bool)
+    @unwrap_spec(fd=int, readable=bool, writable=bool)
     def descr_new_file(space, w_subtype, fd, readable=True, writable=True):
         flags = (readable and READABLE) | (writable and WRITABLE)
 
@@ -240,7 +237,6 @@
         W_FileConnection.__init__(self, fd, flags)
         return space.wrap(self)
 
-    @unwrap_spec('self', ObjSpace)
     def fileno(self, space):
         return space.wrap(self.fd)
 
@@ -350,7 +346,7 @@
         W_BaseConnection.__init__(self, flags)
         self.handle = handle
 
-    @unwrap_spec(ObjSpace, W_Root, W_Root, bool, bool)
+    @unwrap_spec(readable=bool, writable=bool)
     def descr_new_pipe(space, w_subtype, w_handle, readable=True, writable=True):
         from pypy.module._multiprocessing.interp_win32 import handle_w
         handle = handle_w(space, w_handle)
@@ -369,7 +365,6 @@
     def is_valid(self):
         return self.handle != self.INVALID_HANDLE_VALUE
 
-    @unwrap_spec('self', ObjSpace)
     def fileno(self, space):
         return w_handle(space, self.handle)
 

diff --git a/pypy/module/_multiprocessing/interp_memory.py b/pypy/module/_multiprocessing/interp_memory.py
--- a/pypy/module/_multiprocessing/interp_memory.py
+++ b/pypy/module/_multiprocessing/interp_memory.py
@@ -1,10 +1,7 @@
-from pypy.interpreter.baseobjspace import ObjSpace, Wrappable, W_Root
-from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.error import OperationError
 from pypy.rpython.lltypesystem import rffi
 from pypy.module.mmap.interp_mmap import W_MMap
 
- at unwrap_spec(ObjSpace, W_Root)
 def address_of_buffer(space, w_obj):
     if space.config.objspace.usemodules.mmap:
         mmap = space.interp_w(W_MMap, w_obj)

diff --git a/pypy/module/_multiprocessing/interp_win32.py b/pypy/module/_multiprocessing/interp_win32.py
--- a/pypy/module/_multiprocessing/interp_win32.py
+++ b/pypy/module/_multiprocessing/interp_win32.py
@@ -1,4 +1,4 @@
-from pypy.interpreter.gateway import ObjSpace, W_Root, unwrap_spec, interp2app
+from pypy.interpreter.gateway import unwrap_spec, interp2app
 from pypy.interpreter.function import StaticMethod
 from pypy.interpreter.error import wrap_windowserror, OperationError
 from pypy.rlib import rwin32
@@ -104,7 +104,8 @@
 # __________________________________________________________
 # functions for the "win32" namespace
 
- at unwrap_spec(ObjSpace, str, r_uint, r_uint, r_uint, r_uint, r_uint, r_uint, W_Root)
+ at unwrap_spec(name=str, openmode=r_uint, pipemode=r_uint, maxinstances=r_uint,
+             outputsize=r_uint, inputsize=r_uint, timeout=r_uint)
 def CreateNamedPipe(space, name, openmode, pipemode, maxinstances,
                     outputsize, inputsize, timeout, w_security):
     security = space.int_w(w_security)
@@ -129,7 +130,6 @@
     if not _ConnectNamedPipe(handle, rffi.NULL):
         raise wrap_windowserror(space, rwin32.lastWindowsError())
 
- at unwrap_spec(ObjSpace, W_Root, W_Root, W_Root, W_Root)
 def SetNamedPipeHandleState(space, w_handle, w_pipemode, w_maxinstances, w_timeout):
     handle = handle_w(space, w_handle)
     state = lltype.malloc(rffi.CArrayPtr(rffi.UINT).TO, 3, flavor='raw')
@@ -150,13 +150,14 @@
         lltype.free(state, flavor='raw')
         lltype.free(statep, flavor='raw')
 
- at unwrap_spec(ObjSpace, str, r_uint)
+ at unwrap_spec(name=str, timeout=r_uint)
 def WaitNamedPipe(space, name, timeout):
     # Careful: zero means "default value specified by CreateNamedPipe()"
     if not _WaitNamedPipe(name, timeout):
         raise wrap_windowserror(space, rwin32.lastWindowsError())
 
- at unwrap_spec(ObjSpace, str, r_uint, r_uint, W_Root, r_uint, r_uint, W_Root)
+ at unwrap_spec(filename=str, access=r_uint, share=r_uint,
+             disposition=r_uint, flags=r_uint)
 def CreateFile(space, filename, access, share, w_security,
                disposition, flags, w_templatefile):
     security = space.int_w(w_security)
@@ -173,7 +174,7 @@
 
     return w_handle(space, handle)
 
- at unwrap_spec(ObjSpace, r_uint)
+ at unwrap_spec(code=r_uint)
 def ExitProcess(space, code):
     _ExitProcess(code)
 


More information about the Pypy-commit mailing list