Author: Alex Gaynor <alex.gay...@gmail.com> Branch: Changeset: r67862:cab5c44a5677 Date: 2013-11-05 22:31 -0800 http://bitbucket.org/pypy/pypy/changeset/cab5c44a5677/
Log: Handle weird indices here, don't try to pass length = -1 down to append_charpsize diff --git a/pypy/module/mmap/interp_mmap.py b/pypy/module/mmap/interp_mmap.py --- a/pypy/module/mmap/interp_mmap.py +++ b/pypy/module/mmap/interp_mmap.py @@ -163,6 +163,8 @@ if step == 0: # index only return space.wrap(self.mmap.getitem(start)) elif step == 1: + if stop - start < 0: + return space.wrap("") return space.wrap(self.mmap.getslice(start, stop - start)) else: res = "".join([self.mmap.getitem(i) diff --git a/pypy/module/mmap/test/test_mmap.py b/pypy/module/mmap/test/test_mmap.py --- a/pypy/module/mmap/test/test_mmap.py +++ b/pypy/module/mmap/test/test_mmap.py @@ -525,6 +525,8 @@ m = mmap(f.fileno(), 6) assert m[-3:7] == "bar" + assert m[1:0:1] == "" + f.close() def test_sequence_type(self): diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py --- a/rpython/rlib/rstring.py +++ b/rpython/rlib/rstring.py @@ -371,6 +371,7 @@ self._grow(times) def append_charpsize(self, s, size): + assert size >= 0 l = [] for i in xrange(size): l.append(s[i]) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit