Current `mmap` implementation raises a ValueError if a sum of offset and length exceeds file size, as reported by `fstat`. While perfectly valid for most use-cases, it doesn't work for "special" files, for example:
>>> with open("/proc/sys/debug/exception-trace", "r+b") as f:
... mmap.mmap(f.fileno(), 0)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ValueError: mmap offset is greater than file size
Same goes for almost any other /proc file, because most of them have S_ISREG() == True and st_size = 0.
How about adding a keyword argument to `mmap.mmap()`, which disables fstat-based size checks? |