[ctypes-commit] ctypes/source callproc.c,1.100,1.101 _ctypes.c,1.154,1.155
Brought to you by:
theller
|
From: Thomas H. <th...@us...> - 2004-09-01 12:04:09
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31816 Modified Files: callproc.c _ctypes.c Log Message: Allow to call cdecl functions with more arguments than the length of the argtypes attribute, even if this is set. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** callproc.c 26 Aug 2004 19:59:21 -0000 1.100 --- callproc.c 1 Sep 2004 12:03:56 -0000 1.101 *************** *** 818,822 **** PyObject *restype) { ! int i, n, argcount; struct argument result; struct argument *args, *pa; --- 818,822 ---- PyObject *restype) { ! int i, n, argcount, argtype_count; struct argument result; struct argument *args, *pa; *************** *** 832,836 **** args = (struct argument *)alloca(sizeof(struct argument) * argcount); memset(args, 0, sizeof(struct argument) * argcount); ! if (pIunk) { args[0].ffi_type = &ffi_type_pointer; --- 832,836 ---- args = (struct argument *)alloca(sizeof(struct argument) * argcount); memset(args, 0, sizeof(struct argument) * argcount); ! argtype_count = argtypes ? PyTuple_GET_SIZE(argtypes) : 0; if (pIunk) { args[0].ffi_type = &ffi_type_pointer; *************** *** 848,852 **** arg = PyTuple_GET_ITEM(argtuple, i); /* borrowed ref */ ! if (argtypes) { PyObject *v; converter = PyTuple_GET_ITEM(argtypes, i); --- 848,856 ---- arg = PyTuple_GET_ITEM(argtuple, i); /* borrowed ref */ ! /* For cdecl functions, we allow more actual arguments ! than the length of the argtypes tuple. ! This is checked in _ctypes::CFuncPtr_Call ! */ ! if (argtypes && argtype_count > i) { PyObject *v; converter = PyTuple_GET_ITEM(argtypes, i); Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -d -r1.154 -r1.155 *** _ctypes.c 27 Aug 2004 12:04:14 -0000 1.154 --- _ctypes.c 1 Sep 2004 12:03:57 -0000 1.155 *************** *** 2454,2458 **** required ++; #endif ! if (required != actual) { PyErr_Format(PyExc_TypeError, "this function takes %d argument%s (%d given)", --- 2454,2470 ---- required ++; #endif ! if (dict->flags & FUNCFLAG_CDECL == FUNCFLAG_CDECL) { ! /* For cdecl functions, we allow more actual arguments ! than the length of the argtypes tuple. ! */ ! if (required > actual) { ! PyErr_Format(PyExc_TypeError, ! "this function takes at least %d argument%s (%d given)", ! required, ! required == 1 ? "" : "s", ! actual); ! return NULL; ! } ! } else if (required != actual) { PyErr_Format(PyExc_TypeError, "this function takes %d argument%s (%d given)", |