[pypy-commit] pypy default: Backport changes from py3.5
arigo
pypy.commits at gmail.com
Tue Jan 17 11:47:16 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r89634:97d138151271
Date: 2017-01-17 17:46 +0100
http://bitbucket.org/pypy/pypy/changeset/97d138151271/
Log: Backport changes from py3.5
diff --git a/rpython/rlib/rStringIO.py b/rpython/rlib/rStringIO.py
--- a/rpython/rlib/rStringIO.py
+++ b/rpython/rlib/rStringIO.py
@@ -1,4 +1,5 @@
from rpython.rlib.rstring import StringBuilder
+from rpython.rlib.objectmodel import we_are_translated
AT_END = -1
@@ -154,8 +155,11 @@
assert p >= 0
self.__copy_into_bigbuffer()
end = len(self.__bigbuffer)
- if size >= 0 and size < end - p:
+ count = end - p
+ if size >= 0 and size < count:
end = p + size
+ if count <= 0:
+ return ''
i = p
while i < end:
finished = self.__bigbuffer[i] == '\n'
@@ -163,6 +167,11 @@
if finished:
break
self.__pos = i
+ if not we_are_translated():
+ # assert that we read within the bounds!
+ bl = len(self.__bigbuffer)
+ assert p <= bl
+ assert i <= bl
return ''.join(self.__bigbuffer[p:i])
def truncate(self, size):
diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -1474,6 +1474,8 @@
# This function is also used by _codecs/interp_codecs.py
(unicode_encode_unicode_escape, raw_unicode_escape_helper
) = make_unicode_escape_function()
+(_, raw_unicode_escape_helper_unicode
+) = make_unicode_escape_function(unicode_output=True)
# ____________________________________________________________
# Raw unicode escape
diff --git a/rpython/rlib/test/test_rStringIO.py b/rpython/rlib/test/test_rStringIO.py
--- a/rpython/rlib/test/test_rStringIO.py
+++ b/rpython/rlib/test/test_rStringIO.py
@@ -91,6 +91,10 @@
assert f.readline() == 'baz'
assert f.readline() == ''
+ f.seek(100000, 0)
+ assert f.tell() == 100000
+ assert f.readline() == ''
+
def test_truncate():
f = RStringIO()
f.truncate(20)
More information about the pypy-commit
mailing list