Eryk Sun <eryk...@gmail.com> added the comment:

> Just out of curiosity, where is this data coming from?

In general it's just random data on the stack. It's not worth investigating 
where this particular value comes from. It could be the low word of the address 
of a stack-allocated buffer, such as the buffer where ffi_call writes the 
return value.

> This ONLY way to prevent things like this to happen is to actually 
> correctly configure the function:
> ...
> >>> mul_ints.argtypes = (ctypes.c_int16, ctypes.c_int16)

Yes, the docs should explain that TypeError is raised for the wrong number of 
arguments when argtypes is assigned, and it should be noted that cdecl (CDLL) 
allows passing more (but not fewer) arguments than what argtypes defines. As I 
mentioned previously, we could extend this cdecl behavior to stdcall (WinDLL) 
for the x64 architecture, since it's caller cleanup like cdecl.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38258>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to