classification
Title: "tarfile.ReadError: file could not be opened successfully" if compiled without zlib
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: lars.gustaebel Nosy List: eric.araujo, flox, haypo, lars.gustaebel
Priority: low Keywords:

Created on 2010-06-11 21:48 by flox, last changed 2011-02-08 13:03 by eric.araujo.

Messages (4)
msg107587 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-06-11 21:48
When Python is compiled without zlib support, the error message is not very helpful when trying to untar an archive.

>>> tarfile.open('sample.tar.gz')
tarfile.ReadError: file could not be opened successfully

It happens when you run "python distribute_setup.py", for example.
 ( http://s3.pixane.com/pip_distribute.png )
msg107589 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2010-06-11 21:53
Which message do you suggest?
msg107592 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-06-11 22:00
something like :
  raise CompressionError("zlib module is not available")
msg107643 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2010-06-12 10:33
If you pass an explicit mode, the error message is more or less what you want:

>>> tarfile.open("uga.tgz", mode="r:gz")
[...]
tarfile.CompressionError: gzip module is not available

The way mode="r" detects which compression format is used is to open the file with each open method (i.e. taropen, gzopen, bz2open) until one of them succeeds. If none of them matches it is impossible to say what the reason was.

As this would require more than just a simple one-line change, 2.7 is out of the question. But I see what I can do for 3.2.
History
Date User Action Args
2011-02-08 13:03:48eric.araujosetnosy: + eric.araujo

versions: + Python 3.3, - Python 3.2
2010-06-12 10:33:10lars.gustaebelsetmessages: + msg107643
versions: - Python 2.7
2010-06-11 22:03:07floxsetnosy: lars.gustaebel, haypo, flox
components: + Library (Lib), - Extension Modules
2010-06-11 22:00:17floxsetmessages: + msg107592
2010-06-11 21:55:23pitrousetassignee: lars.gustaebel

nosy: + lars.gustaebel
2010-06-11 21:53:15hayposetnosy: + haypo
messages: + msg107589
2010-06-11 21:48:52floxcreate