Skip to content

mmap: incorrect find/rfind results for empty subsequences #8722

Description

@doma17

Summary

mmap.rfind(b"") returns the start of the search range instead of its end.
Both find() and rfind() also report a match for an empty subsequence
when start > end.

Reproduced on RustPython main at 0ba7048ac, compared with CPython 3.14.7.

Reproducer

import mmap

with mmap.mmap(-1, 3) as m:
    m[:] = b"abc"
    print(m.rfind(b""))
    print(m.rfind(b"", 1, 2))
    print(m.find(b"", 2, 1))
    print(m.rfind(b"", 2, 1))

Expected (CPython 3.14.7)

3
2
-1
-1

Actual (RustPython)

0
1
2
2

Reference

https://docs.python.org/3/library/mmap.html#mmap.mmap.rfind

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions