[pypy-commit] pypy py3.5-ssl: check if end has reached when UnpackFormatIterator walks in backward direction

plan_rich pypy.commits at gmail.com
Fri Dec 2 07:47:13 EST 2016


Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5-ssl
Changeset: r88818:fb36dd2e7878
Date: 2016-12-02 12:43 +0100
http://bitbucket.org/pypy/pypy/changeset/fb36dd2e7878/

Log:	check if end has reached when UnpackFormatIterator walks in backward
	direction

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
@@ -127,12 +127,11 @@
         self.pos = (self.pos + mask) & ~mask
 
     def finished(self):
-        if self.strides:
-            # FIXME richard
-            pass
-        else:
-            if self.pos != self.length:
-                raise StructError("unpack str size too long for format")
+        value = self.pos
+        if self.strides and self.strides[0] < 0:
+                value = -self.pos
+        if value != self.length:
+            raise StructError("unpack str size too long for format")
 
     def read(self, count):
         if self.strides:


More information about the pypy-commit mailing list