[pypy-issue] Issue #2703: PyPy3 bitfields reversed from expected value (pypy/pypy)
Holger Grund
issues-reply at bitbucket.org
Tue Nov 21 04:16:11 EST 2017
New issue 2703: PyPy3 bitfields reversed from expected value
https://bitbucket.org/pypy/pypy/issues/2703/pypy3-bitfields-reversed-from-expected
Holger Grund:
Bitfields in BigendianStructures are not allocated in the same way as for CPython on x86-64 Linux at least.
Per ABI big-endian bitfields should be allocated from high to low bit, but PyPy’s ctypes doesn’t do that.
Observe:
```
#!python
import ctypes
class Foo(ctypes.BigEndianStructure):
_fields_ = (
('first', ctypes.c_uint8, 4),
('second', ctypes.c_uint8, 4))
f = Foo(first=0,second=15)
print('%r' % list(bytes(f)))
```
PyPy3 prints [240].
CPython prints [15].
More information about the pypy-issue
mailing list