[issue28631] [2.7/3.5/3.6 Regression] crash using ctypes
Eryk Sun
report at bugs.python.org
Mon Nov 7 12:43:14 EST 2016
Eryk Sun added the comment:
po_message_create() returns a po_message_t pointer:
/* A po_message_t represents a message in a PO file. */
typedef struct po_message *po_message_t;
/* Return a freshly constructed message.
To finish initializing the message, you must set the msgid
and msgstr. */
extern po_message_t po_message_create (void);
You're casting a pointer as a 32-bit C int, which isn't reliable in 64-bit Python. The value 0x55c7cf00 (1439158016) may be truncated. Try it using a po_message_t pointer type. For example:
gpo = ctypes.CDLL(lib_location)
class po_message_t(ctypes._Pointer):
"""A po_message_t represents a message in a PO file."""
class po_message(ctypes.Structure):
pass
_type_ = po_message
gpo.po_message_create.restype = po_message_t
----------
nosy: +eryksun
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28631>
_______________________________________
More information about the Python-bugs-list
mailing list