[pypy-svn] pypy improve-unwrap_spec: Simplify unwrap_spec in the oracle module
amauryfa
commits-noreply at bitbucket.org
Wed Feb 16 19:20:05 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: improve-unwrap_spec
Changeset: r42080:dc7c35233392
Date: 2011-02-16 17:47 +0100
http://bitbucket.org/pypy/pypy/changeset/dc7c35233392/
Log: Simplify unwrap_spec in the oracle module
diff --git a/pypy/module/oracle/interp_pool.py b/pypy/module/oracle/interp_pool.py
--- a/pypy/module/oracle/interp_pool.py
+++ b/pypy/module/oracle/interp_pool.py
@@ -1,7 +1,7 @@
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.argument import Arguments, Signature
-from pypy.interpreter.gateway import ObjSpace, W_Root, NoneNotWrapped
-from pypy.interpreter.gateway import interp2app
+from pypy.interpreter.gateway import NoneNotWrapped
+from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
from pypy.interpreter.error import OperationError
@@ -17,6 +17,8 @@
def __init__(self):
self.environment = None
+ @unwrap_spec(min=int, max=int, increment=int,
+ threaded=bool, getmode=int, events=bool, homogeneous=bool)
def descr_new(space, w_subtype,
w_user, w_password, w_dsn,
min, max, increment,
@@ -105,11 +107,6 @@
dsn_buf.clear()
return space.wrap(self)
- descr_new.unwrap_spec = [ObjSpace, W_Root,
- W_Root, W_Root, W_Root,
- int, int, int,
- W_Root,
- bool, int, bool, bool]
def checkConnected(self, space):
if not self.handle:
@@ -136,15 +133,12 @@
__args__.keywords + ["pool"],
__args__.keywords_w + [space.wrap(self)])
return space.call_args(self.w_connectionType, newargs)
- acquire.unwrap_spec = ['self', ObjSpace, Arguments]
def release(self, space, w_connection):
self._release(space, w_connection, roci.OCI_DEFAULT)
- release.unwrap_spec = ['self', ObjSpace, W_Root]
def drop(self, space, w_connection):
self._release(space, w_connection, roci.OCI_SESSRLS_DROPSESS)
- drop.unwrap_spec = ['self', ObjSpace, W_Root]
def _release(self, space, w_connection, mode):
from pypy.module.oracle.interp_connect import W_Connection
diff --git a/pypy/module/oracle/interp_object.py b/pypy/module/oracle/interp_object.py
--- a/pypy/module/oracle/interp_object.py
+++ b/pypy/module/oracle/interp_object.py
@@ -1,8 +1,7 @@
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.typedef import interp_attrproperty
-from pypy.interpreter.gateway import ObjSpace
-from pypy.interpreter.gateway import interp2app
+from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import OperationError
from pypy.rpython.lltypesystem import rffi, lltype
@@ -344,6 +343,7 @@
self.indicator = indicator
self.isIndependent = isIndependent
+ @unwrap_spec(attr=str)
def getattr(self, space, attr):
try:
attribute = self.objectType.attributesByName[attr]
@@ -405,8 +405,6 @@
lltype.free(nameptr, flavor='raw')
lltype.free(namelenptr, flavor='raw')
- getattr.unwrap_spec = ['self', ObjSpace, str]
-
W_ExternalObject.typedef = TypeDef(
'ExternalObject',
type = interp_attrproperty('objectType', W_ExternalObject),
diff --git a/pypy/module/oracle/interp_variable.py b/pypy/module/oracle/interp_variable.py
--- a/pypy/module/oracle/interp_variable.py
+++ b/pypy/module/oracle/interp_variable.py
@@ -1,8 +1,7 @@
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.typedef import TypeDef
from pypy.interpreter.typedef import interp_attrproperty
-from pypy.interpreter.gateway import ObjSpace, W_Root
-from pypy.interpreter.gateway import interp2app
+from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import OperationError
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.rlib.rarithmetic import ovfcheck
@@ -390,11 +389,11 @@
[self.getSingleValue(space, i)
for i in range(numElements)])
+ @unwrap_spec(pos=int)
def getValue(self, space, pos=0):
if self.isArray:
return self.getArrayValue(space, self.actualElementsPtr[0])
return self.getSingleValue(space, pos)
- getValue.unwrap_spec = ['self', ObjSpace, int]
def setSingleValue(self, space, pos, w_value):
# ensure we do not exceed the number of allocated elements
@@ -437,12 +436,12 @@
for i in range(len(elements_w)):
self.setSingleValue(space, i, elements_w[i])
+ @unwrap_spec(pos=int)
def setValue(self, space, pos, w_value):
if self.isArray:
self.setArrayValue(space, w_value)
else:
self.setSingleValue(space, pos, w_value)
- setValue.unwrap_spec = ['self', ObjSpace, int, W_Root]
W_Variable.typedef = TypeDef(
diff --git a/pypy/module/oracle/interp_lob.py b/pypy/module/oracle/interp_lob.py
--- a/pypy/module/oracle/interp_lob.py
+++ b/pypy/module/oracle/interp_lob.py
@@ -1,7 +1,6 @@
from pypy.interpreter.baseobjspace import Wrappable
from pypy.interpreter.typedef import TypeDef
-from pypy.interpreter.gateway import ObjSpace
-from pypy.interpreter.gateway import interp2app
+from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import OperationError
from pypy.module.oracle.interp_error import get
@@ -19,24 +18,22 @@
space.wrap(
"LOB variable no longer valid after subsequent fetch"))
+ @unwrap_spec(offset=int, amount=int)
def read(self, space, offset=-1, amount=-1):
self._verify(space)
return self.lobVar.read(space, self.pos, offset, amount)
- read.unwrap_spec = ['self', ObjSpace, int, int]
def size(self, space):
self._verify(space)
return space.wrap(self.lobVar.getLength(space, self.pos))
- size.unwrap_spec = ['self', ObjSpace]
+ @unwrap_spec(newSize=int)
def trim(self, space, newSize=0):
self._verify(space)
self.lobVar.trim(space, self.pos, newSize)
- trim.unwrap_spec = ['self', ObjSpace, int]
def desc_str(self, space):
return self.read(space, offset=1, amount=-1)
- desc_str.unwrap_spec = ['self', ObjSpace]
W_ExternalLob.typedef = TypeDef(
'ExternalLob',
diff --git a/pypy/module/oracle/interp_connect.py b/pypy/module/oracle/interp_connect.py
--- a/pypy/module/oracle/interp_connect.py
+++ b/pypy/module/oracle/interp_connect.py
@@ -1,5 +1,5 @@
from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.gateway import ObjSpace, W_Root, NoneNotWrapped
+from pypy.interpreter.gateway import unwrap_spec, NoneNotWrapped
from pypy.interpreter.typedef import (TypeDef, interp_attrproperty_w,
GetSetProperty)
from pypy.interpreter.gateway import interp2app
@@ -30,6 +30,10 @@
self.w_version = None
self.release = False
+
+ @unwrap_spec(mode=int, handle=int,
+ threaded=bool, twophase=bool, events=bool,
+ purity=bool)
def descr_new(space, w_subtype,
w_user=NoneNotWrapped,
w_password=NoneNotWrapped,
@@ -77,15 +81,6 @@
self.connect(space, mode, twophase)
return space.wrap(self)
- descr_new.unwrap_spec = [ObjSpace, W_Root,
- W_Root, W_Root, W_Root,
- int, int,
- W_Root,
- bool, bool, bool,
- W_Root,
- int,
- W_Root]
-
def __del__(self):
if self.release:
roci.OCITransRollback(
@@ -418,7 +413,6 @@
roci.OCIHandleFree(self.handle, roci.OCI_HTYPE_SVCCTX)
self.handle = lltype.nullptr(roci.OCISvcCtx.TO)
- close.unwrap_spec = ['self', ObjSpace]
def commit(self, space):
# make sure we are actually connected
@@ -431,7 +425,6 @@
status, "Connection_Commit()")
self.commitMode = roci.OCI_DEFAULT
- commit.unwrap_spec = ['self', ObjSpace]
def rollback(self, space):
# make sure we are actually connected
@@ -442,11 +435,9 @@
roci.OCI_DEFAULT)
self.environment.checkForError(
status, "Connection_Rollback()")
- rollback.unwrap_spec = ['self', ObjSpace]
def newCursor(self, space):
return space.wrap(W_Cursor(space, self))
- newCursor.unwrap_spec = ['self', ObjSpace]
def _getCharacterSetName(self, space, attribute):
# get character set id
@@ -525,8 +516,7 @@
W_Connection.typedef = TypeDef(
"Connection",
- __new__ = interp2app(W_Connection.descr_new.im_func,
- unwrap_spec=W_Connection.descr_new.unwrap_spec),
+ __new__ = interp2app(W_Connection.descr_new.im_func),
username = interp_attrproperty_w('w_username', W_Connection),
password = interp_attrproperty_w('w_password', W_Connection),
tnsentry = interp_attrproperty_w('w_tnsentry', W_Connection),
diff --git a/pypy/module/oracle/interp_cursor.py b/pypy/module/oracle/interp_cursor.py
--- a/pypy/module/oracle/interp_cursor.py
+++ b/pypy/module/oracle/interp_cursor.py
@@ -1,9 +1,8 @@
from pypy.interpreter.baseobjspace import Wrappable
-from pypy.interpreter.gateway import ObjSpace, W_Root, NoneNotWrapped
-from pypy.interpreter.argument import Arguments
+from pypy.interpreter.gateway import NoneNotWrapped
from pypy.interpreter.typedef import TypeDef, GetSetProperty
from pypy.interpreter.typedef import interp_attrproperty, interp_attrproperty_w
-from pypy.interpreter.gateway import interp2app
+from pypy.interpreter.gateway import interp2app, unwrap_spec
from pypy.interpreter.error import OperationError
from pypy.rpython.lltypesystem import rffi, lltype
@@ -68,7 +67,6 @@
self._checkOpen(space)
return self._execute(space, w_stmt, w_vars)
- execute.unwrap_spec = ['self', ObjSpace, W_Root, Arguments]
def prepare(self, space, w_stmt, w_tag=None):
# make sure the cursor is open
@@ -76,7 +74,6 @@
# prepare the statement
self._internalPrepare(space, w_stmt, w_tag)
- prepare.unwrap_spec = ['self', ObjSpace, W_Root, W_Root]
def _execute(self, space, w_stmt, w_vars):
@@ -153,7 +150,6 @@
# zero since Oracle raises an error otherwise
if numrows > 0:
self._internalExecute(space, numIters=numrows)
- executemany.unwrap_spec = ['self', ObjSpace, W_Root, W_Root]
def close(self, space):
# make sure we are actually open
@@ -164,8 +160,8 @@
self.isOpen = False
self.handle = lltype.nullptr(roci.OCIStmt.TO)
- close.unwrap_spec = ['self', ObjSpace]
+ @unwrap_spec(name=str)
def callfunc(self, space, name, w_returnType, w_parameters=None):
retvar = interp_variable.newVariableByType(space, self, w_returnType, 1)
if space.is_w(w_parameters, space.w_None):
@@ -175,8 +171,8 @@
# determine the results
return retvar.getValue(space, 0)
- callfunc.unwrap_spec = ['self', ObjSpace, str, W_Root, W_Root]
+ @unwrap_spec(name=str)
def callproc(self, space, name, w_parameters=None):
if space.is_w(w_parameters, space.w_None):
w_parameters = None
@@ -191,8 +187,6 @@
ret_w.append(v.getValue(space, 0))
return space.newlist(ret_w)
- callproc.unwrap_spec = ['self', ObjSpace, str, W_Root]
-
def _call(self, space, name, retvar, w_args):
# determine the number of arguments passed
if w_args:
@@ -768,7 +762,6 @@
return self._createRow(space)
return space.w_None
- fetchone.unwrap_spec = ['self', ObjSpace]
def fetchmany(self, space, w_numRows=NoneNotWrapped):
if w_numRows is not None:
@@ -780,19 +773,16 @@
self._verifyFetch(space)
return self._multiFetch(space, limit=numRows)
- fetchmany.unwrap_spec = ['self', ObjSpace, W_Root]
def fetchall(self, space):
# verify fetch can be performed
self._verifyFetch(space)
return self._multiFetch(space, limit=0)
- fetchall.unwrap_spec = ['self', ObjSpace]
def descr_iter(self, space):
self._verifyFetch(space)
return space.wrap(self)
- descr_iter.unwrap_spec = ['self', ObjSpace]
def descr_next(self, space):
# verify fetch can be performed
@@ -803,7 +793,6 @@
return self._createRow(space)
raise OperationError(space.w_StopIteration, space.w_None)
- descr_next.unwrap_spec = ['self', ObjSpace]
def _moreRows(self, space):
if self.rowNum < self.actualRows:
@@ -964,8 +953,8 @@
if nbElements:
_, names = self._get_bind_info(space, nbElements)
return space.newlist(names)
- bindnames.unwrap_spec = ['self', ObjSpace]
+ @unwrap_spec(size=int)
def var(self, space, w_type, size=0, w_arraysize=None,
w_inconverter=None, w_outconverter=None):
if space.is_w(w_arraysize, space.w_None):
@@ -984,8 +973,8 @@
var.w_outconverter = w_outconverter
return space.wrap(var)
- var.unwrap_spec = ['self', ObjSpace, W_Root, int, W_Root, W_Root, W_Root]
+ @unwrap_spec(size=int)
def arrayvar(self, space, w_type, w_value, size=0):
# determine the type of variable
varType = interp_variable.typeByPythonType(space, self, w_type)
@@ -1011,7 +1000,6 @@
var.setArrayValue(space, w_value)
return var
- arrayvar.unwrap_spec = ['self', ObjSpace, W_Root, W_Root, int]
def setinputsizes(self, space, __args__):
args_w, kw_w = __args__.unpack()
@@ -1051,12 +1039,11 @@
space, self, w_value, self.bindArraySize)
self.bindList[i] = var
return space.newlist(self.bindList)
- setinputsizes.unwrap_spec = ['self', ObjSpace, Arguments]
+ @unwrap_spec(outputSize=int, outputSizeColumn=int)
def setoutputsize(self, space, outputSize, outputSizeColumn=-1):
self.outputSize = outputSize
self.outputSizeColumn = outputSizeColumn
- setoutputsize.unwrap_spec = ['self', ObjSpace, int, int]
def arraysize_get(space, self):
More information about the Pypy-commit
mailing list