[issue5887] mmap.write_byte out of bounds - no error, position gets screwed up

Brian Mearns report at bugs.python.org
Thu Apr 30 20:28:20 CEST 2009


New submission from Brian Mearns <bmearns at ieee.org>:

Created an mmap for a file in update mode, seek to end of file, and
invoke write_byte. The file is not updated (as expected), but did not
get any error indicating the write was out of bounds, and when I invoke
tell(), it reports a position that is out of bounds. I check size(), and
it still reports the correct size (less than the value reported by
tell()). If I do seek(0, os.SEEK_END), it correctly returns to the end
of the map, instead of this bizarre no-mans land beyond the end.

This is on Windows XP.

Here's an example from the shell. (note that write() works as I would
expect, it raises an exception and doesn't modify the position):

>>> map.tell()
0
>>> map.size()
8
>>> map.seek(0, os.SEEK_END)
>>> map.tell()
8
>>> map.write("foo")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: data out of range
>>> map.tell()
8
>>> map.size()
8
>>> map.write_byte('x')
>>> map.tell()
9
>>> map.size()
8
>>> print "WTF?"
WTF?
>>> map.write_byte('x')
>>> map.tell()
10
>>> map.size()
8
>>> map.flush()
1
>>> map.size()
8
>>> map.tell()
10
>>> map.seek(0, os.SEEK_END)
>>> map.tell()
8
>>> map.size()
8
>>>

----------
messages: 86848
nosy: bmearns
severity: normal
status: open
title: mmap.write_byte out of bounds - no error, position gets screwed up
type: behavior
versions: Python 2.6

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


More information about the Python-bugs-list mailing list