New submission from Eric Pruitt:
When buffering data from a file, the buffered I/O does not take into account
the current file descriptor position. In the following example, I open a file
and seek forward 1,000 bytes:
>>> f = open("test-file", "rb")
>>> f.seek(1000)
1000
>>> f.readline()
The filesystem on which "test-file" resides has a block size of 4,096 bytes, so
on the backend, I would expect Python to read 3,096 bytes so the next read will
be aligned with the filesystem blocks. What actually happens is that Python
reads a 4,096 bytes. This is the output from an strace attached to the
interpreter above:
Process 16543 attached
lseek(4, 0, SEEK_CUR) = 0
lseek(4, 1000, SEEK_SET) = 1000
read(4, "\000\000\000\000\000\000\000\000\000\000"..., 4096) = 4096
----------
components: IO
messages: 246931
nosy: ericpruitt
priority: normal
severity: normal
status: open
title: Buffered I/O does not take file position into account when reading blocks
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue24666>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com