[New-bugs-announce] [issue12945] ctypes works incorrectly with _swappedbytes_ = 1
Pavel Boldin
report at bugs.python.org
Fri Sep 9 15:54:49 CEST 2011
New submission from Pavel Boldin <boldin.pavel at gmail.com>:
ctypes seems to work incorrectly with _swappedbytes_ specified.
I.e. it misses some values from buffer:
class X(ctypes.Structure):
_swappedbytes_ = 1
_pack_ = 1
_fields_ = [
('a', ctypes.c_ubyte, 4),
('b', ctypes.c_ubyte, 4),
('c', ctypes.c_ushort, 8),
('d', ctypes.c_ushort, 8),
]
buf = '\x12\x34\x56\x78'
x = X.from_buffer_copy(buf)
print x.a == 1
print x.b == 2
print x.c == 3
print x.d == 4
This prints
True
True
False
False
Where as four 'True' are expected.
----------
components: ctypes
files: test_ctypes.py
messages: 143761
nosy: Pavel.Boldin
priority: normal
severity: normal
status: open
title: ctypes works incorrectly with _swappedbytes_ = 1
versions: Python 2.7, Python 3.1
Added file: http://bugs.python.org/file23122/test_ctypes.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12945>
_______________________________________
More information about the New-bugs-announce
mailing list