Author: Brian Kearns <[email protected]>
Branch: py3k
Changeset: r71255:9f5a42a7419d
Date: 2014-05-04 01:17 -0400
http://bitbucket.org/pypy/pypy/changeset/9f5a42a7419d/

Log:    marshal.loads use buffers correctly

diff --git a/pypy/module/marshal/interp_marshal.py 
b/pypy/module/marshal/interp_marshal.py
--- a/pypy/module/marshal/interp_marshal.py
+++ b/pypy/module/marshal/interp_marshal.py
@@ -466,9 +466,9 @@
     # Unmarshaller with inlined buffer string
     def __init__(self, space, w_str):
         Unmarshaller.__init__(self, space, None)
-        self.bufstr = space.getarg_w('s#', w_str)
+        self.buf = space.getarg_w('y*', w_str)
         self.bufpos = 0
-        self.limit = len(self.bufstr)
+        self.limit = self.buf.getlength()
 
     def raise_eof(self):
         space = self.space
@@ -481,14 +481,14 @@
         if newpos > self.limit:
             self.raise_eof()
         self.bufpos = newpos
-        return self.bufstr[pos : newpos]
+        return self.buf.getslice(pos, newpos, 1, newpos - pos)
 
     def get1(self):
         pos = self.bufpos
         if pos >= self.limit:
             self.raise_eof()
         self.bufpos = pos + 1
-        return self.bufstr[pos]
+        return self.buf.getitem(pos)
 
     def get_int(self):
         pos = self.bufpos
@@ -496,10 +496,10 @@
         if newpos > self.limit:
             self.raise_eof()
         self.bufpos = newpos
-        a = ord(self.bufstr[pos])
-        b = ord(self.bufstr[pos+1])
-        c = ord(self.bufstr[pos+2])
-        d = ord(self.bufstr[pos+3])
+        a = ord(self.buf.getitem(pos))
+        b = ord(self.buf.getitem(pos+1))
+        c = ord(self.buf.getitem(pos+2))
+        d = ord(self.buf.getitem(pos+3))
         if d & 0x80:
             d -= 0x100
         x = a | (b<<8) | (c<<16) | (d<<24)
@@ -511,10 +511,10 @@
         if newpos > self.limit:
             self.raise_eof()
         self.bufpos = newpos
-        a = ord(self.bufstr[pos])
-        b = ord(self.bufstr[pos+1])
-        c = ord(self.bufstr[pos+2])
-        d = ord(self.bufstr[pos+3])
+        a = ord(self.buf.getitem(pos))
+        b = ord(self.buf.getitem(pos+1))
+        c = ord(self.buf.getitem(pos+2))
+        d = ord(self.buf.getitem(pos+3))
         x = a | (b<<8) | (c<<16) | (d<<24)
         if x >= 0:
             return x
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to