[New-bugs-announce] [issue24470] ctypes incorrect handling of long int on 64bits Linux

Marco Clemencic report at bugs.python.org
Fri Jun 19 10:35:40 CEST 2015


New submission from Marco Clemencic:

When passing a Python int to a C function expecting long int (or void*) via ctypes, the number gets truncated to 32 bits, even if the args types are correctly declared.
The workaround is to wrap the argument in c_long (or c_void_p), but the automatic unwrapping of c_long (or c_void_p) in the return type lead to undefined behaviour in code like:

myClib.getNumber.restype = c_long
myClib.doSomething.args = [c_long]
l = myClib.getnumber()
myClib.doSomething(l)

----------
components: ctypes
files: test_py.tar.bz2
messages: 245494
nosy: Marco Clemencic
priority: normal
severity: normal
status: open
title: ctypes incorrect handling of long int on 64bits Linux
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file39736/test_py.tar.bz2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24470>
_______________________________________


More information about the New-bugs-announce mailing list