[pypy-commit] pypy default: runpack should align for next read
Sreepathi Pai
pypy.commits at gmail.com
Thu Feb 6 03:58:56 EST 2020
Author: Sreepathi Pai <sree at buckyball>
Branch:
Changeset: r98670:78510e758e34
Date: 2020-02-05 19:03 -0500
http://bitbucket.org/pypy/pypy/changeset/78510e758e34/
Log: runpack should align for next read
diff --git a/rpython/pytest.ini b/rpython/pytest.ini
--- a/rpython/pytest.ini
+++ b/rpython/pytest.ini
@@ -1,2 +1,2 @@
[pytest]
-addopts = --assert=reinterp -rf
+#addopts = --assert=reinterp -rf
diff --git a/rpython/rlib/rstruct/runpack.py b/rpython/rlib/rstruct/runpack.py
--- a/rpython/rlib/rstruct/runpack.py
+++ b/rpython/rlib/rstruct/runpack.py
@@ -86,12 +86,12 @@
for i in rg:
fmtdesc, rep, mask = self.formats[i]
miniglobals['unpacker%d' % i] = fmtdesc.unpack
- if mask is not None:
- perform_lst.append('master_reader.align(%d)' % mask)
if not fmtdesc.needcount:
perform_lst.append('unpacker%d(reader%d)' % (i, i))
else:
perform_lst.append('unpacker%d(reader%d, %d)' % (i, i, rep))
+ if mask is not None:
+ perform_lst.append('master_reader.align(%d)' % mask)
miniglobals['reader_cls%d' % i] = reader_for_pos(i)
readers = ";".join(["reader%d = reader_cls%d(master_reader, bigendian)"
% (i, i) for i in rg])
diff --git a/rpython/rlib/rstruct/test/test_runpack.py b/rpython/rlib/rstruct/test/test_runpack.py
--- a/rpython/rlib/rstruct/test/test_runpack.py
+++ b/rpython/rlib/rstruct/test/test_runpack.py
@@ -110,6 +110,15 @@
assert unpack(">q", '\xbeMLKJIHH') == -0x41B2B3B4B5B6B7B8
assert unpack(">Q", '\x81BCDEFGH') == 0x8142434445464748
+ def test_align(self):
+ data = struct.pack('BBhi', 1, 2, 3, 4)
+ def fn():
+ a, b, c, d = runpack('BBhi', data)
+ return a+(b << 8)+(c << 16) + (d << 32)
+ assert fn() == 0x400030201
+ assert self.interpret(fn, []) == 0x400030201
+
+
class TestNoFastPath(TestRStruct):
More information about the pypy-commit
mailing list