[pypy-svn] r51004 - in pypy/dist/pypy/lib: _ctypes app_test/ctypes
fijal at codespeak.net
fijal at codespeak.net
Fri Jan 25 01:24:09 CET 2008
Author: fijal
Date: Fri Jan 25 01:24:09 2008
New Revision: 51004
Modified:
pypy/dist/pypy/lib/_ctypes/function.py
pypy/dist/pypy/lib/app_test/ctypes/test_functions.py
Log:
Another patological case, when there are some arguments for function
specified, but not enough
Modified: pypy/dist/pypy/lib/_ctypes/function.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/function.py (original)
+++ pypy/dist/pypy/lib/_ctypes/function.py Fri Jan 25 01:24:09 2008
@@ -67,6 +67,13 @@
argtypes = self._argtypes_
if argtypes is None:
argtypes = self._guess_argtypes(args)
+ else:
+ dif = len(args) - len(argtypes)
+ if dif < 0:
+ raise TypeError("Not enough arguments")
+ if dif > 0:
+ cut = len(args) - dif
+ argtypes = argtypes[:] + self._guess_argtypes(args[cut:])
restype = self._restype_
funcptr = self._getfuncptr(argtypes, restype)
resarray = funcptr(*self._wrap_args(argtypes, args))
Modified: pypy/dist/pypy/lib/app_test/ctypes/test_functions.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_functions.py (original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_functions.py Fri Jan 25 01:24:09 2008
@@ -388,6 +388,13 @@
assert (s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h) == (
(9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
+ def test_call_some_args(self):
+ f = dll.my_strchr
+ f.argtypes = [c_char_p]
+ f.restype = c_char_p
+ result = f("abcd", ord("b"))
+ assert result == "bcd"
+
def test_sf1651235(self):
py.test.skip("???")
# see http://www.python.org/sf/1651235
More information about the Pypy-commit
mailing list