Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/test/test_mmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ def test_find_end(self):
self.assertEqual(m.find(b'one', 1, -1), 8)
self.assertEqual(m.find(b'one', 1, -2), -1)
self.assertEqual(m.find(bytearray(b'one')), 0)
self.assertEqual(m.find(b'', n + 1), -1)
self.assertEqual(m.rfind(b'', n + 1), -1)

for i in range(-n-1, n+1):
for j in range(-n-1, n+1):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix :meth:`mmap.mmap.find` and :meth:`~mmap.mmap.rfind` to return ``-1``
when searching for an empty subsequence with a start position past the end
of the mapping.
2 changes: 0 additions & 2 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,6 @@ mmap_gfind_lock_held(mmap_object *self, Py_buffer *view, PyObject *start_obj,
start += self->size;
if (start < 0)
start = 0;
else if (start > self->size)
start = self->size;

if (end < 0)
end += self->size;
Expand Down
Loading