473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

python 2.4: tarfile tell() and seek() seem to be broeken

Hello everyone,

I noticed that when you open a zipped tarball using 'tarfile' and if you
then get the pseudo-file descriptor fd for a file via 'extractfile', then
fd.tell() is broken in the following way:

- before reading anything from fd, fd.tell() will return 0 (that's still
ok)
- after reading a line via fd.readline(), fd.tell() will return a
value different from 0 (still ok, I guess)
- subsequent calls of fd.readline() and fd.tell() will yield the correct
lines but always the same value from fd.tell().

fd.seek() seems to be unaffected from this strange behaviour.

Is there a mistake on my side or does this need fixing?

Best regards,

Niklas Volbers.
Jul 19 '05 #1
3 1862
On Wed, 01 Jun 2005 14:58:23 +0200, N. Volbers wrote:
- subsequent calls of fd.readline() and fd.tell() will yield the correct
lines but always the same value from fd.tell().

Is there a mistake on my side or does this need fixing?


This is a bug. Although the pseudo file object's readline() method returns
the file data line-wise, the data is processed block-wise (100 chars)
internally. Therefore, the output of tell() will always return the
position right after the current block if it is used in conjunction with
readline().

Thank you for pointing that out. I'll take care of this getting fixed.

--
Lars Gustäbel
la**@gustaebel.de

Jul 19 '05 #2
Am Thu, 02 Jun 2005 17:57:20 +0200 schrieb Lars Gustäbel:
On Wed, 01 Jun 2005 14:58:23 +0200, N. Volbers wrote:
- subsequent calls of fd.readline() and fd.tell() will yield the correct
lines but always the same value from fd.tell().
[...]
Thank you for pointing that out. I'll take care of this getting fixed.


Thanks for taking care of it ;-)

Jul 19 '05 #3
On Thu, 02 Jun 2005 19:52:24 +0200, N. Volbers wrote:
Thanks for taking care of it ;-)


I submitted patch #1230446 today which ought to fix the problem.

--
Lars Gustäbel
la**@gustaebel.de

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Lars Behrens | last post by:
Hi, Pythonistas! I'm quite new to Python and have a problem with a simple backup script. This code: tar = tarfile.open('/home/lars/test.tar.gz', 'w:gz') tar.addfile('/home/lars') brings...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 259 open ( -5) / 2573 closed (+17) / 2832 total (+12) Bugs : 745 open ( +0) / 4405 closed (+21) / 5150 total (+21) RFE : 150 open...
8
by: mrstephengross | last post by:
I want to find a way to embed a tar file *in* my python script, and then use the tarfile module to extract it. That is, instead of distributing two files (extractor.py and archive.tar) I want to be...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 407 open ( +3) / 3393 closed (+17) / 3800 total (+20) Bugs : 888 open (+28) / 6145 closed (+14) / 7033 total (+42) RFE : 232 open...
3
by: samwyse | last post by:
I'm a relative newbie to Python, so please bear with me. There are currently two standard modules used to access archived data: zipfile and tarfile. The interfaces are completely different. In...
2
by: tgiles | last post by:
Hi, All! I started back programming Python again after a hiatus of several years and run into a sticky problem that I can't seem to fix, regardless of how hard I try- it it starts with tailing a...
6
by: Terry Carroll | last post by:
I am trying to do something with a very large tarfile from within Python, and am running into memory constraints. The tarfile in question is a 4-gigabyte datafile from freedb.org,...
1
by: boblatest | last post by:
Hello, I'm trying to catch an "EOFError" exception that occurs when reading truncated tarfile. Here's my routine, and below that the callback trace. Note that although I'm trying to catch all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.