[issue43028] seeking past the end of a file unexpected behavior
Christian Heimes
report at bugs.python.org
Tue Jan 26 00:38:32 EST 2021
Christian Heimes <lists at cheimes.de> added the comment:
The high level and low level variants behave the same if you pass in the same flags. You are using the append flag in "open()", but you don't pass the os.O_APPEND flag to "os.open()".
>>> import os
>>> fd = os.open('log', os.O_WRONLY | os.O_APPEND | os.O_CREAT)
>>> os.lseek(fd, 1, os.SEEK_SET)
1
>>> os.write(fd, b'foo')
3
>>> os.close(fd)
>>> os.stat('log').st_size
3
>>> fd = os.open('log2', os.O_WRONLY | os.O_CREAT)
>>> os.lseek(fd, 1, os.SEEK_SET)
1
>>> os.write(fd, b'foo')
3
>>> os.close(fd)
>>> os.stat('log2').st_size
4
----------
nosy: +christian.heimes
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43028>
_______________________________________
More information about the Python-bugs-list
mailing list