[New-bugs-announce] [issue12556] Disable size checks in mmap.mmap()

Sergei Lebedev report at bugs.python.org
Thu Jul 14 15:21:00 CEST 2011


New submission from Sergei Lebedev <superbobry at gmail.com>:

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?

----------
components: Library (Lib)
messages: 140330
nosy: superbobry
priority: normal
severity: normal
status: open
title: Disable size checks in mmap.mmap()
type: feature request
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12556>
_______________________________________


More information about the New-bugs-announce mailing list