[pypy-commit] pypy py3.6: hg merge default
arigo
pypy.commits at gmail.com
Mon Aug 26 11:11:57 EDT 2019
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.6
Changeset: r97267:e4eba87b1754
Date: 2019-08-26 17:04 +0200
http://bitbucket.org/pypy/pypy/changeset/e4eba87b1754/
Log: hg merge default
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -222,6 +222,8 @@
print(' turn off the JIT')
print(' help')
print(' print this page')
+ print()
+ print('The "pypyjit" module can be used to control the JIT from inside python')
def print_version(*args):
initstdio()
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
@@ -131,7 +131,7 @@
"%s() returned too much data: "
"%d bytes requested, %d returned",
methodname, length, len(data))
- rwbuffer.setslice(0, data)
+ self.output_slice(space, rwbuffer, 0, data)
return space.newint(len(data))
W_BufferedIOBase.typedef = TypeDef(
@@ -609,7 +609,7 @@
remaining = n
written = 0
if current_size:
- result_buffer.setslice(
+ self.output_slice(space, result_buffer,
written, self.buffer[self.pos:self.pos + current_size])
remaining -= current_size
written += current_size
@@ -654,7 +654,7 @@
if remaining > 0:
if size > remaining:
size = remaining
- result_buffer.setslice(
+ self.output_slice(space, result_buffer,
written, self.buffer[self.pos:self.pos + size])
self.pos += size
written += size
diff --git a/pypy/module/_io/interp_bytesio.py b/pypy/module/_io/interp_bytesio.py
--- a/pypy/module/_io/interp_bytesio.py
+++ b/pypy/module/_io/interp_bytesio.py
@@ -92,7 +92,7 @@
size = rwbuffer.getlength()
output = self.read(size)
- rwbuffer.setslice(0, output)
+ self.output_slice(space, rwbuffer, 0, output)
return space.newint(len(output))
def write_w(self, space, w_data):
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -475,7 +475,7 @@
return space.w_None
wrap_oserror(space, e, exception_name='w_IOError',
eintr_retry=True)
- rwbuffer.setslice(0, buf)
+ self.output_slice(space, rwbuffer, 0, buf)
return space.newint(len(buf))
else:
# optimized case: reading more than 64 bytes into a rwbuffer
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -308,6 +308,14 @@
else:
break
+ @staticmethod
+ def output_slice(space, rwbuffer, target_pos, data):
+ if target_pos + len(data) > rwbuffer.getlength():
+ raise oefmt(space.w_RuntimeError,
+ "target buffer has shrunk during operation")
+ rwbuffer.setslice(target_pos, data)
+
+
W_IOBase.typedef = TypeDef(
'_io._IOBase',
__new__ = generic_new_descr(W_IOBase),
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -1042,6 +1042,11 @@
return rutf8.codepoint_position_at_index(
self._utf8, self._get_index_storage(), index)
+ def _codepoints_in_utf8(self, start, end):
+ if self.is_ascii():
+ return end - start
+ return rutf8.codepoints_in_utf8(self._utf8, start, end)
+
@always_inline
def _unwrap_and_search(self, space, w_sub, w_start, w_end, forward=True):
w_sub = self.convert_arg_to_w_unicode(space, w_sub)
@@ -1063,7 +1068,7 @@
res_index = self._utf8.find(w_sub._utf8, start_index, end_index)
if res_index < 0:
return None
- skip = rutf8.codepoints_in_utf8(self._utf8, start_index, res_index)
+ skip = self._codepoints_in_utf8(start_index, res_index)
res = start + skip
assert res >= 0
return space.newint(res)
@@ -1071,7 +1076,7 @@
res_index = self._utf8.rfind(w_sub._utf8, start_index, end_index)
if res_index < 0:
return None
- skip = rutf8.codepoints_in_utf8(self._utf8, res_index, end_index)
+ skip = self._codepoints_in_utf8(res_index, end_index)
res = end - skip
assert res >= 0
return space.newint(res)
More information about the pypy-commit
mailing list