[pypy-svn] r50639 - in pypy/branch/applevel-ctypes2/pypy/module/_rawffi: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Jan 15 17:03:12 CET 2008
Author: arigo
Date: Tue Jan 15 17:03:11 2008
New Revision: 50639
Modified:
pypy/branch/applevel-ctypes2/pypy/module/_rawffi/interp_rawffi.py
pypy/branch/applevel-ctypes2/pypy/module/_rawffi/test/test__rawffi.py
Log:
(fijal, arigo)
Accept any pointer letter as argument to functions taking pointers.
Modified: pypy/branch/applevel-ctypes2/pypy/module/_rawffi/interp_rawffi.py
==============================================================================
--- pypy/branch/applevel-ctypes2/pypy/module/_rawffi/interp_rawffi.py (original)
+++ pypy/branch/applevel-ctypes2/pypy/module/_rawffi/interp_rawffi.py Tue Jan 15 17:03:11 2008
@@ -328,10 +328,13 @@
msg = ("Argument %d should be an array of length 1, "
"got length %d" % (i+1, arg.length))
raise OperationError(space.w_TypeError, space.wrap(msg))
- if arg.shape.itemtp[0] != argtype:
- msg = "Argument %d should be typecode %s, got %s" % (
- i+1, argtype, arg.shape.itemtp[0])
- raise OperationError(space.w_TypeError, space.wrap(msg))
+ letter = arg.shape.itemtp[0]
+ if letter != argtype:
+ if not (argtype in TYPEMAP_PTR_LETTERS and
+ letter in TYPEMAP_PTR_LETTERS):
+ msg = "Argument %d should be typecode %s, got %s" % (
+ i+1, argtype, letter)
+ raise OperationError(space.w_TypeError, space.wrap(msg))
args_ll.append(arg.ll_buffer)
# XXX we could avoid the intermediate list args_ll
if self.resarray is not None:
Modified: pypy/branch/applevel-ctypes2/pypy/module/_rawffi/test/test__rawffi.py
==============================================================================
--- pypy/branch/applevel-ctypes2/pypy/module/_rawffi/test/test__rawffi.py (original)
+++ pypy/branch/applevel-ctypes2/pypy/module/_rawffi/test/test__rawffi.py Tue Jan 15 17:03:11 2008
@@ -201,7 +201,7 @@
def test_time(self):
import _rawffi
libc = _rawffi.CDLL('libc.so.6')
- time = libc.ptr('time', ['P'], 'l')
+ time = libc.ptr('time', ['z'], 'l') # 'z' instead of 'P' just for test
arg = _rawffi.Array('P')(1)
arg[0] = 0
res = time(arg)
More information about the Pypy-commit
mailing list