mirror of
https://github.com/python/cpython.git
synced 2026-02-06 09:50:43 +00:00
Merge 39cc479e02 into b6d8aa436b
This commit is contained in:
commit
98536bd3b4
3 changed files with 14 additions and 1 deletions
|
|
@ -130,6 +130,14 @@ def c_string(init):
|
|||
def test_abstract(self):
|
||||
self.assertRaises(TypeError, _CFuncPtr, 13, "name", 42, "iid")
|
||||
|
||||
def test_invalid_argtypes(self):
|
||||
libc = CDLL(None)
|
||||
|
||||
PRINTF_PROTO = CFUNCTYPE(c_int, ctypes.c_char_p)
|
||||
c_printf = PRINTF_PROTO(("printf", libc), ((1,),))
|
||||
c_printf.argtypes = (c_char_p, c_int)
|
||||
with self.assertRaises(TypeError):
|
||||
c_printf(b"Hello\n")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix segfaults in _cyptes during _build_callargs.
|
||||
|
|
@ -4373,7 +4373,11 @@ _build_callargs(ctypes_state *st, PyCFuncPtrObject *self, PyObject *argtypes,
|
|||
callargs = PyTuple_New(len); /* the argument tuple we build */
|
||||
if (callargs == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!_validate_paramflags(st, Py_TYPE(self), argtypes)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"the current argument is invalid");
|
||||
goto error;
|
||||
}
|
||||
#ifdef MS_WIN32
|
||||
/* For a COM method, skip the first arg */
|
||||
if (self->index) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue