tarfile.open(mode='w:gz'|'w|gz'|..., fileobj=StringIO()) fails.

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue May 27 11:32:26 EDT 2008


En Tue, 27 May 2008 02:43:53 -0300, sebastian.noack at googlemail.com  
<sebastian.noack at googlemail.com> escribió:

> On May 27, 2:17 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
> wrote:
>> It's not a bug, you must extract the StringIO contents *after* closing
>> tar_file, else you won't get the last blocks pending to be written.
>
> I looked at tarfile's source code last night after I wrote this
> message and figured it out. But the problem is that TarFile's close
> method closes the underlying file object after the last block is
> written and when you close StringIO you can not get its content
> anymore. Wtf does it close the underlying file? There is absolute no
> reason for doing this. Are you still sure this isn't a bug?

Ouch, sorry, I only tried with gzip (and worked fine), not bz2 (which is  
buggy).

-- 
Gabriel Genellina




More information about the Python-list mailing list