`mmap` objects does not support __contains__ operation with ints (unlike bytearray!)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
The following code
import mmap
with open('test.dat', 'wb') as f:
f.write(b'A')
with open('test.dat', 'rb') as f:
mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
print(65 in memoryview(mm))
print(65 in bytearray(mm))
print(65 in mm)
mm.close()
prints
True
True
False
this even though mmap documentation claims that mmap works exactly like bytearray.
There is also discrepancy in the __iter__ implementation, but for that there is a workaround of using a memoryview object and that would be possibly backwards-incompatible change.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the issue's mmap, memoryview, and bytearray reproduction on Linux with CPython main. Trace the mmap object's containment behavior and add or update coverage for integer membership; done means mmap matches the documented bytearray behavior without regressing the noted iteration behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100