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 <rep...@bugs.python.org>
<http://bugs.python.org/issue24470>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to