New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing SWAP_INT in I_set_sw #67508
Comments
I_set_sw function is missing a SWAP_INT. This leads to wrong set of bitfield value. Here is a script to reproduce: ---------- from ctypes import *
class HEADER(BigEndianStructure):
_fields_ = ( ('pad', c_uint32, 16),
('v1', c_uint32, 4),
('v2', c_uint32, 12)
)
b = bytearray(4)
header = HEADER.from_buffer(b)
header.type = 1
assert b == b'\x00\x00\x10\x00'
header.mode = 0x234
assert b == b'\x00\x00\x12\x34' |
A little ping. With a new patch integrating the unit test. |
I will review this today. |
The bug is also present in Python 2.7. Is it possible to backport this fix ? |
New changeset 935ae7f001e3 by Victor Stinner in branch '3.4': |
New changeset 88f2c4f12b56 by Victor Stinner in branch '2.7': |
Thanks for your report, patch and unit test Matthieu. I rewrote the unit test because your layout was too complex for my little brain :-) I also write a unit test for little endian. I applied your fix to Python 2.7, 3.4, 3.5 and 3.6. |
New changeset 12b353f76447 by Victor Stinner in branch '2.7': New changeset 3caa68f55e3e by Victor Stinner in branch '3.4': |
Thanks for committing this Victor. The patch looked good to me too. Sorry for not getting around to update the tracker. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: