This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tarfile.py: ExFileObject\'s tell() is wrong after readline()
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: lars.gustaebel Nosy List: lars.gustaebel
Priority: normal Keywords: patch

Created on 2005-06-30 16:23 by lars.gustaebel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tarfile-exfileobj.diff lars.gustaebel, 2005-06-30 16:23 patch to Lib/tarfile.py and Lib/test/test_tarfile.py
Messages (2)
msg48539 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2005-06-30 16:23
This patch is intended to be the solution to a problem
that Niklas Volbers reported on comp.lang.python on
June 1st.
ExFileObject is the pseudo file object that is returned
by TarFile.extractfile() and allows a user to read a
file from the tar archive using a file interface.
Niklas discovered that the tell() method didn't give
correct results if he used it in conjunction with
readline().
The cause for this is that readline() buffers the file
data in 100 char blocks to be able to split it into
lines. Thus, tell() always returns the file position in
100 byte steps.
While I was looking for a fix to that problem in
tarfile.py, I discovered that ExFileObject has another
flaw as well: I read in readline()'s docstring that
mixing calls to read() and readline() is not allowed,
which is nowhere documented. I decided to put a little
effort into a rewrite of ExFileObject.
Here it is, tests included.

msg48540 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2006-12-23 16:52
Committed as rev. 53153 and rev. 53154 (2.5).
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42146
2005-06-30 16:23:29lars.gustaebelcreate