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

Discussion in 'Python' started by N. Volbers, Jun 1, 2005.

  1. N. Volbers

    N. Volbers Guest

    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.
     
    N. Volbers, Jun 1, 2005
    #1
    1. Advertising

  2. 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
     
    =?iso-8859-1?q?Lars_Gust=E4bel?=, Jun 2, 2005
    #2
    1. Advertising

  3. N. Volbers

    N. Volbers Guest

    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 ;-)
     
    N. Volbers, Jun 2, 2005
    #3
  4. 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
     
    =?iso-8859-1?q?Lars_Gust=E4bel?=, Jun 30, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Prabhu Ramachandran

    Trouble with file.seek/file.tell on Win32?

    Prabhu Ramachandran, Aug 15, 2004, in forum: Python
    Replies:
    0
    Views:
    442
    Prabhu Ramachandran
    Aug 15, 2004
  2. Tim Peters
    Replies:
    0
    Views:
    622
    Tim Peters
    Aug 15, 2004
  3. Prabhu Ramachandran

    Re: Trouble with file.seek/file.tell on Win32?

    Prabhu Ramachandran, Aug 16, 2004, in forum: Python
    Replies:
    2
    Views:
    513
    Christos TZOTZIOY Georgiou
    Aug 16, 2004
  4. Ben Temperton
    Replies:
    1
    Views:
    267
    Emile van Sebille
    Jun 14, 2012
  5. Replies:
    3
    Views:
    150
    Andreas Perstinger
    May 14, 2013
Loading...

Share This Page