[Patches] [ python-Patches-1230446 ] tarfile.py: ExFileObject\'s tell() is wrong after readline()

SourceForge.net noreply at sourceforge.net
Thu Dec 21 09:51:53 CET 2006


Patches item #1230446, was opened at 2005-06-30 18:23
Message generated for change (Settings changed) made by gustaebel
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1230446&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Lars Gustäbel (gustaebel)
>Assigned to: Lars Gustäbel (gustaebel)
>Summary: tarfile.py: ExFileObject\'s tell() is wrong after readline()

Initial Comment:
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.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1230446&group_id=5470


More information about the Patches mailing list