[pypy-svn] r50582 - pypy/branch/applevel-ctypes2/pypy/rlib
arigo at codespeak.net
arigo at codespeak.net
Mon Jan 14 13:04:55 CET 2008
Author: arigo
Date: Mon Jan 14 13:04:55 2008
New Revision: 50582
Modified:
pypy/branch/applevel-ctypes2/pypy/rlib/libffi.py
Log:
(fijal, arigo) Assert instead of ValueError.
Modified: pypy/branch/applevel-ctypes2/pypy/rlib/libffi.py
==============================================================================
--- pypy/branch/applevel-ctypes2/pypy/rlib/libffi.py (original)
+++ pypy/branch/applevel-ctypes2/pypy/rlib/libffi.py Mon Jan 14 13:04:55 2008
@@ -180,7 +180,6 @@
self.restype = restype
self.funcsym = funcsym
argnum = len(argtypes)
- self.argnum = argnum
self.ll_argtypes = lltype.malloc(FFI_TYPE_PP.TO, argnum, flavor='raw')
for i in range(argnum):
self.ll_argtypes[i] = argtypes[i]
@@ -202,11 +201,9 @@
class RawFuncPtr(AbstractFuncPtr):
def call(self, args_ll, ll_result):
- if len(args_ll) != self.argnum:
- raise ValueError("wrong number of arguments in call to %s(): "
- "%d instead of %d" % (self.name,
- len(args_ll),
- self.argnum))
+ assert len(args_ll) == len(self.argtypes), (
+ "wrong number of arguments in call to %s(): "
+ "%d instead of %d" % (self.name, len(args_ll), len(self.argtypes)))
ll_args = lltype.malloc(rffi.VOIDPP.TO, len(args_ll), flavor='raw')
for i in range(len(args_ll)):
ll_args[i] = args_ll[i]
@@ -221,6 +218,7 @@
def __init__(self, name, argtypes, restype, funcsym):
# initialize each one of pointers with null
AbstractFuncPtr.__init__(self, name, argtypes, restype, funcsym)
+ self.argnum = len(self.argtypes)
self.pushed_args = 0
self.ll_args = lltype.malloc(rffi.VOIDPP.TO, self.argnum, flavor='raw')
for i in range(self.argnum):
More information about the Pypy-commit
mailing list