[issue13148] simple bug in mmap size check

Maxim Yanchenko report at bugs.python.org
Tue Oct 11 03:27:27 CEST 2011


Maxim Yanchenko <maxim.yanchenko at gs.com> added the comment:

First of all, it doesn't fail (at least on Linux), I tested it before posting.

And the latest, it's not like I'm just stalking around and reading Python sources for fun. It's a real and pretty valid case, I hit it while upgrading our production code to python 2.7.
I'm using NumPy (linear algebra module) that uses Python's core mmap module under the hood.
In NumPy, it's pretty valid to have arrays of size 0.
I have a file with a fixed-size header that holds size of the array and some other meta-data. I mmap this file as a NumPy array using the offset equal to header size. Of course, if there is no data in the array then the file will be just header, and the offset will be equal to the size of the file - here is where this bug hits us as I can't load this file with Python 2.7.2 anymore (while I was able to with Python 2.5).
This patch fixes this and everything works as expected, giving an array with zero dimensions ('shape' in terms of NumPy):
>>> x.shape
(0,)
>>> x.size
0

Please kindly consider applying the patch.

----------
resolution: invalid -> 
status: closed -> open

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


More information about the Python-bugs-list mailing list