[pypy-commit] pypy jit-codewriter-force-cast-refactor: merged upstream.

alex_gaynor noreply at buildbot.pypy.org
Sun Aug 28 06:56:05 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: jit-codewriter-force-cast-refactor
Changeset: r46842:a99d9b39366e
Date: 2011-08-28 00:54 -0400
http://bitbucket.org/pypy/pypy/changeset/a99d9b39366e/

Log:	merged upstream.

diff --git a/pypy/module/struct/formatiterator.py b/pypy/module/struct/formatiterator.py
--- a/pypy/module/struct/formatiterator.py
+++ b/pypy/module/struct/formatiterator.py
@@ -154,6 +154,13 @@
         self.inputpos = end
         return s
 
+    def get_pos_and_advance(self, count):
+        pos = self.inputpos
+        self.inputpos += count
+        if self.inputpos > len(self.input):
+            raise StructError("unpack str size too short for format")
+        return pos
+
     def appendobj(self, value):
         self.result_w.append(self.space.wrap(value))
     appendobj._annspecialcase_ = 'specialize:argtype(1)'
diff --git a/pypy/rlib/rstruct/standardfmttable.py b/pypy/rlib/rstruct/standardfmttable.py
--- a/pypy/rlib/rstruct/standardfmttable.py
+++ b/pypy/rlib/rstruct/standardfmttable.py
@@ -198,8 +198,8 @@
     @specialize.argtype(0)
     def unpack_int(fmtiter):
         intvalue = inttype(0)
-        s = fmtiter.read(size)
-        idx = 0
+        s = fmtiter.input
+        idx = fmtiter.get_pos_and_advance(size)
         if fmtiter.bigendian:
             for i in unroll_range_size:
                 x = ord(s[idx])


More information about the pypy-commit mailing list