cpython/Lib/ctypes
Pauli Virtanen 2d1653aa43 [3.6] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31) (#3241)
Ctypes currently produces wrong pep3118 type codes for several types.
E.g. memoryview(ctypes.c_long()).format gives "<l" on 64-bit platforms,
but it should be "<q" instead for sizeof(c_long) == 8

The problem is that the '<>' endian specification in the struct syntax
also turns on the "standard size" mode, which makes type characters have
a platform-independent meaning, which does not match with the codes used
internally in ctypes.  The struct module format syntax also does not
allow specifying native-size non-native-endian items.

This commit adds a converter function that maps the internal ctypes
codes to appropriate struct module standard-size codes in the pep3118
format strings. The tests are modified to check for this.
(cherry picked from commit 07f1658aa0)
2017-08-30 11:40:05 +02:00
..
macholib [3.6] Use Travis to make sure all generated files are up to date (GH-2080) (GH-2092) 2017-06-11 11:30:57 -05:00
test [3.6] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31) (#3241) 2017-08-30 11:40:05 +02:00
__init__.py Issue #29219: Fixed infinite recursion in the repr of uninitialized 2017-01-13 09:42:17 +02:00
_endian.py Issue #22098: ctypes' BigEndianStructure and LittleEndianStructure now define an empty __slots__ so that subclasses don't always get an instance dict. 2014-08-30 00:37:18 +02:00
util.py Issue #27355: Removed support for Windows CE. It was never finished, 2016-09-05 15:11:23 -07:00
wintypes.py Issue #3612: Added new types to ctypes.wintypes. (CHAR and pointers) 2010-09-28 21:08:38 +00:00