Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: 3.2 can't extract tarfile produced by 2.7

Reply
Thread Tools

Re: 3.2 can't extract tarfile produced by 2.7

 
 
Ian Kelly
Guest
Posts: n/a
 
      12-27-2012
On Thu, Dec 27, 2012 at 11:50 AM, Steven W. Orr <(E-Mail Removed)> wrote:
> Really? I thought that the whole idea of using "rb" or "wb" was something
> that was necessitated by WinBlo$e. We're not doing IO on a text file here.
> It's a tar file which by definition is binary and it's not clear to me why
> unicode has anything to do with it. The files you extract should be
> unaffected and the archive you produce shouldn't care. Am I missing
> something?


Python 3 uses the 'b' mode to signify that a binary stream should be
opened instead of a text stream. A binary stream returns bytes when
read from. A text stream returns strings when read from, which means
that the bytes must be decoded; it also performs optional newline
conversion. For full details, see the io module documentation.

You're correct that it makes no sense to open a tar file in binary
mode, but the basic io.open constructor has no concept of file type
and relies on the caller to specify the mode properly. The tarfile
module has its own tarfile.open function which has no "text mode";
this is generally the correct way to open a tar file. For some reason
the OP is not using this but is instead opening the file with io.open
(in the wrong mode) and then passing the already-opened file object to
tarfile.open.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: 3.2 can't extract tarfile produced by 2.7 Ian Kelly Python 0 12-27-2012 07:27 PM
Re: 3.2 can't extract tarfile produced by 2.7 Steven W. Orr Python 0 12-27-2012 06:50 PM
3.2 can't extract tarfile produced by 2.7 Antoon Pardon Python 0 12-26-2012 03:56 PM
How do i extract vidios when winrar wont extract them??? help plzzzzzzzz smuttdog@sc.rr.com Computer Support 2 12-23-2007 07:03 AM
umask option for tarfile extract Faik Uygur Python 0 06-15-2006 11:42 AM



Advertisments