2d1653aa43
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
|
||
---|---|---|
.. | ||
__init__.py | ||
__main__.py | ||
test_anon.py | ||
test_array_in_pointer.py | ||
test_arrays.py | ||
test_as_parameter.py | ||
test_bitfields.py | ||
test_buffers.py | ||
test_bytes.py | ||
test_byteswap.py | ||
test_callbacks.py | ||
test_cast.py | ||
test_cfuncs.py | ||
test_checkretval.py | ||
test_delattr.py | ||
test_errno.py | ||
test_find.py | ||
test_frombuffer.py | ||
test_funcptr.py | ||
test_functions.py | ||
test_incomplete.py | ||
test_init.py | ||
test_internals.py | ||
test_keeprefs.py | ||
test_libc.py | ||
test_loading.py | ||
test_macholib.py | ||
test_memfunctions.py | ||
test_numbers.py | ||
test_objects.py | ||
test_parameters.py | ||
test_pep3118.py | ||
test_pickling.py | ||
test_pointers.py | ||
test_prototypes.py | ||
test_python_api.py | ||
test_random_things.py | ||
test_refcounts.py | ||
test_repr.py | ||
test_returnfuncptrs.py | ||
test_simplesubclasses.py | ||
test_sizes.py | ||
test_slicing.py | ||
test_stringptr.py | ||
test_strings.py | ||
test_struct_fields.py | ||
test_structures.py | ||
test_unaligned_structures.py | ||
test_unicode.py | ||
test_values.py | ||
test_varsize_struct.py | ||
test_win32.py | ||
test_wintypes.py |