Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35635

Re: 3.2 can't extract tarfile produced by 2.7

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'binary': 0.05; 'caller': 0.07; 'constructor': 0.07; 'newline': 0.07; 'performs': 0.07; 'properly.': 0.07; 'python': 0.09; 'mode,': 0.09; 'subject:2.7': 0.09; 'archive': 0.11; 'dec': 0.15; 'passing': 0.15; '"rb"': 0.16; "'b'": 0.16; 'mode)': 0.16; 'really?': 0.16; 'stream.': 0.16; 'tarfile': 0.16; 'wrote:': 0.17; 'bytes': 0.17; "shouldn't": 0.17; 'specify': 0.17; 'thu,': 0.17; 'unicode': 0.17; '(in': 0.18; 'module': 0.19; 'file.': 0.20; 'idea': 0.24; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'optional': 0.29; 'relies': 0.29; 'steven': 0.29; 'tar': 0.29; 'definition': 0.29; "we're": 0.30; 'mode': 0.30; 'basic': 0.30; 'function': 0.30; 'sense': 0.31; 'file': 0.32; 'generally': 0.32; 'extract': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'wrong': 0.34; 'clear': 0.35; 'open': 0.35; 'doing': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'anything': 0.36; 'should': 0.36; 'uses': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'object': 0.38; 'some': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'details,': 0.65; 'to:name:python': 0.84; 'from.': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=vXZKKGHrL1QUFe4g8Y56enI3OxvXumCyDZiDoMF0KYM=; b=J0xjSp205jMkfnOCnSOd4MstfnIyd17Rf4yebXjtDEM2NF3TPx8MwbFEqA4JuH/Uvz BvHUS/1fe9S60rPnycjFlcA6IGQOHWas+2JsQKCu8pAgouxHNxyWtUPk9msQLOciC1jD P/bd6ay8joC9HdWSwbGOEP1WZ6dbxoyqanFyrY1jqBxFv12+2TFzKyLlFChAxKndhpV+ WVwrfn6Ywva6iUo3po113/JzOVqK9eUvpd54bgi6mMCAZ/hLbGZcjnI+yFTsEMQH5Xyb /XQ1O4hAS/fh6PKYwLDR0aJSnxiTWxziw3LVWNXQLWCAz1BGMd1EaxtTqL7we5YOOBzb otMA==
MIME-Version 1.0
In-Reply-To <50DC986C.6010202@syslang.net>
References <50DB1E1F.7010404@rece.vub.ac.be> <CAMuTYXjAaWGRt_615uj3pJngcKd9yxy3mnPSET7GQqHwfVJ5mA@mail.gmail.com> <50DC986C.6010202@syslang.net>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 27 Dec 2012 12:25:13 -0700
Subject Re: 3.2 can't extract tarfile produced by 2.7
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1355.1356636347.29569.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1356636347 news.xs4all.nl 6869 [2001:888:2000:d::a6]:47808
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:35635

Show key headers only | View raw


On Thu, Dec 27, 2012 at 11:50 AM, Steven W. Orr <steveo@syslang.net> 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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: 3.2 can't extract tarfile produced by 2.7 Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-27 12:25 -0700

csiph-web