This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年06月11日 21:48 by flox, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 24850 | merged | Anthony Sottile, 2021年03月13日 22:05 | |
| Messages (13) | |||
|---|---|---|---|
| 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 (vstinner) * (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.
|
|||
| msg263880 - (view) | Author: Lars Gustäbel (lars.gustaebel) * (Python committer) | Date: 2016年04月21日 05:25 | |
Closed after years of inactivity. |
|||
| msg330408 - (view) | Author: Kevin Funk (kfunk) | Date: 2018年11月26日 10:10 | |
I just ran into this, under Python 3.6. IMHO, the error message should be improved, even when the mode was not passed explicitly. Can someone reopen this? |
|||
| msg330411 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2018年11月26日 10:16 | |
> I just ran into this, under Python 3.6. How did you install Python? What is your OS? |
|||
| msg330413 - (view) | Author: Kevin Funk (kfunk) | Date: 2018年11月26日 10:24 | |
It's Python 3.6 from CentOS 6. In my particular case I'm lacking the lzma module. But for figuring that out I had to add the explicit modes to the `tarfile.open` calls in my Python script. |
|||
| msg330415 - (view) | Author: Kevin Funk (kfunk) | Date: 2018年11月26日 10:35 | |
(Sorry: I just noticed the Python 3.6 I'm using is /not/ from distro packages. The issue remains, though, the Python exception could be more descriptive.) |
|||
| msg365153 - (view) | Author: Deep Sukhwani (Deep Sukhwani) | Date: 2020年03月27日 14:19 | |
Hello, I just observed this issue on Python 3.8.2 while running tests for Django project.
Example error
======================================================================
ERROR: test_extract_function (utils_tests.test_archive.TestArchive) [foobar.tar.xz]
----------------------------------------------------------------------
Traceback (most recent call last):
...
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
Python version: 3.8.2
OS: macOS Catalina 10.15.4
This should be reopened?
|
|||
| msg380322 - (view) | Author: Jordan Williams (jwillikers) | Date: 2020年11月04日 13:47 | |
This issue took me a long time to diagnose when attempting to decompress a bzip2-compressed tarball. This occurs with Python 3.9.0. Since I was using asdf, which uses Pyenv internally, to build and manage my Python version, I failed to notice it was missing development libraries. A slightly more informative message could easily have tipped me off to this in short order. |
|||
| msg388791 - (view) | Author: Anthony Sottile (Anthony Sottile) * | Date: 2021年03月16日 00:05 | |
I took a stab at improving the error message (see the linked PR)
$ ./python -c 'import tarfile; tarfile.open("Lib/test/testtar.tar.xz")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/asottile/workspace/cpython/Lib/tarfile.py", line 1620, in open
raise ReadError(f"file could not be opened successfully:\n{error_msgs}")
tarfile.ReadError: file could not be opened successfully:
- method gz: ReadError('not a gzip file')
- method bz2: CompressionError('bz2 module is not available')
- method xz: CompressionError('lzma module is not available')
- method tar: ReadError('truncated header')
|
|||
| msg392111 - (view) | Author: miss-islington (miss-islington) | Date: 2021年04月27日 17:39 | |
New changeset 9aea31deddf7458be3546f72185740f3cd06687f by Anthony Sottile in branch 'master': bpo-8978: improve tarfile.open error message when lzma / bz2 are missing (GH-24850) https://github.com/python/cpython/commit/9aea31deddf7458be3546f72185740f3cd06687f |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:02 | admin | set | github: 53224 |
| 2021年04月27日 20:54:24 | vstinner | set | nosy:
- vstinner |
| 2021年04月27日 17:39:07 | miss-islington | set | nosy:
+ miss-islington messages: + msg392111 |
| 2021年03月16日 00:05:55 | Anthony Sottile | set | messages: + msg388791 |
| 2021年03月13日 22:05:16 | Anthony Sottile | set | nosy:
+ Anthony Sottile pull_requests: + pull_request23611 |
| 2020年11月04日 13:47:47 | jwillikers | set | versions:
+ Python 3.9, - Python 3.3 nosy: + jwillikers messages: + msg380322 type: behavior -> crash |
| 2020年03月27日 14:19:55 | Deep Sukhwani | set | nosy:
+ Deep Sukhwani messages: + msg365153 |
| 2018年11月26日 10:35:32 | kfunk | set | messages: + msg330415 |
| 2018年11月26日 10:24:16 | kfunk | set | messages: + msg330413 |
| 2018年11月26日 10:16:17 | vstinner | set | messages: + msg330411 |
| 2018年11月26日 10:10:01 | kfunk | set | nosy:
+ kfunk messages: + msg330408 |
| 2016年04月21日 05:25:39 | lars.gustaebel | set | status: open -> closed resolution: works for me messages: + msg263880 stage: resolved |
| 2011年02月08日 13:03:48 | eric.araujo | set | nosy:
+ eric.araujo versions: + Python 3.3, - Python 3.2 |
| 2010年06月12日 10:33:10 | lars.gustaebel | set | messages:
+ msg107643 versions: - Python 2.7 |
| 2010年06月11日 22:03:07 | flox | set | nosy:
lars.gustaebel, vstinner, flox components: + Library (Lib), - Extension Modules |
| 2010年06月11日 22:00:17 | flox | set | messages: + msg107592 |
| 2010年06月11日 21:55:23 | pitrou | set | assignee: lars.gustaebel nosy: + lars.gustaebel |
| 2010年06月11日 21:53:15 | vstinner | set | nosy:
+ vstinner messages: + msg107589 |
| 2010年06月11日 21:48:52 | flox | create | |