◐ Shell
clean mode source ↗

bpo-10746: ctypes: Fix PEP 3118 type codes for c_long, c_bool, c_int by pv · Pull Request #31 · python/cpython

pitrou

pitrou

pitrou

pv added a commit to pv/cpython that referenced this pull request

Aug 30, 2017
…_int (pythonGH-31)

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 07f1658)

pitrou pushed a commit that referenced this pull request

Aug 30, 2017
…_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 07f1658)

pitrou pushed a commit that referenced this pull request

Sep 2, 2017
…_int (GH-31) (#3242)

[2.7] bpo-10746: Fix ctypes PEP 3118 type codes for c_long, c_bool, c_int (GH-31)

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 07f1658)

GadgetSteve pushed a commit to GadgetSteve/cpython that referenced this pull request

Sep 10, 2017
…ython#31)

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.

jaraco pushed a commit that referenced this pull request

Dec 2, 2022
There were cases where data["commit"]["committer"] is null.

jaraco pushed a commit to jaraco/cpython that referenced this pull request

Feb 17, 2023

nanjekyejoannah added a commit to nanjekyejoannah/cpython that referenced this pull request

Jul 28, 2023
31: Only warn in file init r=ltratt a=nanjekyejoannah

Fixes python#29 

Co-authored-by: Joannah Nanjekye <jnanjeky@unb.ca>

This was referenced

Feb 11, 2025

picnixz added a commit to picnixz/cpython that referenced this pull request

Dec 8, 2025
* re-order imports

* simplify static type definition

* fix undefined behaviors

* reject keyword arguments for `lazy_import`

@Qanux Qanux mentioned this pull request

Feb 11, 2026