Author: Ronan Lamy <[email protected]>
Branch: py3.5
Changeset: r93115:36daba4180a3
Date: 2017-11-21 17:02 +0000
http://bitbucket.org/pypy/pypy/changeset/36daba4180a3/
Log: Advance self.pos also when reading only from self.buffer
diff --git a/pypy/module/_io/interp_bufferedio.py
b/pypy/module/_io/interp_bufferedio.py
--- a/pypy/module/_io/interp_bufferedio.py
+++ b/pypy/module/_io/interp_bufferedio.py
@@ -890,6 +890,7 @@
have = self._readahead()
if have >= length:
rwbuffer.setslice(0, self.buffer[self.pos:self.pos + length])
+ self.pos += length
return space.newint(length)
written = 0
if have > 0:
diff --git a/pypy/module/_io/test/test_bufferedio.py
b/pypy/module/_io/test/test_bufferedio.py
--- a/pypy/module/_io/test/test_bufferedio.py
+++ b/pypy/module/_io/test/test_bufferedio.py
@@ -214,6 +214,15 @@
assert n == 1
assert buf[:n] == b'c'
+ bufio = _io.BufferedReader(MockIO(), buffer_size=20)
+ buf = bytearray(2)
+ bufio.peek(3)
+ assert bufio.readinto1(buf) == 2
+ assert buf == b'ab'
+ n = bufio.readinto1(buf)
+ assert n == 1
+ assert buf[:n] == b'c'
+
def test_seek(self):
import _io
raw = _io.FileIO(self.tmpfile)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit