`mmap` objects does not support __contains__ operation with ints (unlike bytearray!)
未關閉
還沒有人認領這個 Issue。
extension-modules
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先在 Linux 上使用 CPython main 執行 issue 中針對 mmap、memoryview 和 bytearray 的重現。追蹤 mmap 物件的包含行為,並新增或更新整數成員關係的測試涵蓋率;完成條件是 mmap 與文件所述的 bytearray 行為一致,同時不回歸已指出的迭代行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- operating-systems
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100