You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ctypes c_long & c_bool have incorrect PEP-3118 type codes #54955
This is invalid on 64-bit platforms: the above means 32-bit little-endian float. The '<' endian specification turns on the "standard size" mode (similarly as for the struct module), which makes type character have a platform-independent meaning.
Unfortunately, the struct module format syntax does *not* allow specifying native-size non-native-endian items. So just replacing '<' by '^' cannot be in general be done.
Suggested fix attached. It adds a converter function that maps the platform-dependent ctypes codes to struct module standard-size codes; handling c_long and c_bool specially.
New changeset 07f1658 by Antoine Pitrou (Pauli Virtanen) in branch 'master': bpo-10746: Fix ctypes PEP-3118 type codes for c_long, c_bool, c_int (#31) 07f1658
Activity
pv commentedon Dec 20, 2010
Currently on Python 3.x:
This is invalid on 64-bit platforms: the above means 32-bit little-endian float. The '<' endian specification turns on the "standard size" mode (similarly as for the struct module), which makes type character have a platform-independent meaning.
Unfortunately, the struct module format syntax does *not* allow specifying native-size non-native-endian items. So just replacing '<' by '^' cannot be in general be done.
Suggested fix attached. It adds a converter function that maps the platform-dependent ctypes codes to struct module standard-size codes; handling c_long and c_bool specially.
After this patch (and the one in http://bugs.python.org/issue10744 ):
BreamoreBoy commentedon Jun 17, 2014
Could someone do a patch review on this please.
pv commentedon Feb 14, 2017
Converted patch to Github PR + some cleanup.
csabella commentedon Jun 6, 2017
Added the names from the experts list to this ticket.
pitrou commentedon Aug 28, 2017
New changeset 07f1658 by Antoine Pitrou (Pauli Virtanen) in branch 'master':
bpo-10746: Fix ctypes PEP-3118 type codes for c_long, c_bool, c_int (#31)
07f1658
pitrou commentedon Aug 28, 2017
Pauli, do you want to submit backport PRs? This can be done using the cherry_picker script: https://devguide.python.org/committing/?highlight=cherry_picker#backporting-changes-to-an-older-version
pv commentedon Aug 30, 2017
Created backport PR for 3.6: #3241
Which versions take backports?
pitrou commentedon Aug 30, 2017
At this point, 2.7 and 3.6 do.
pitrou commentedon Aug 30, 2017
New changeset 2d1653a by Antoine Pitrou (Pauli Virtanen) in branch '3.6':
[3.6] bpo-10746: Fix ctypes PEP-3118 type codes for c_long, c_bool, c_int (GH-31) (bpo-3241)
2d1653a
pitrou commentedon Sep 2, 2017
New changeset 990b2d0 by Antoine Pitrou (Pauli Virtanen) in branch '2.7':
[2.7] bpo-10746: Fix ctypes PEP-3118 type codes for c_long, c_bool, c_int (GH-31) (bpo-3242)
990b2d0