8000 bpo-8978: improve tarfile.open error message when lzma / bz2 are missing by asottile · Pull Request #24850 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-8978: improve tarfile.open error message when lzma / bz2 are missing #24850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

asottile
Copy link
Contributor
@asottile asottile commented Mar 13, 2021

https://bugs.python.org/issue8978

Automerge-Triggered-By: GH:pablogsal

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 13, 2021
for comptype in sorted(cls.OPEN_METH, key=not_compressed):
func = getattr(cls, cls.OPEN_METH[comptype])
if fileobj is not None:
saved_pos = fileobj.tell()
try:
return func(name, "r", fileobj, **kwargs)
except (ReadError, CompressionError):
except (ReadError, CompressionError) as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with this, but this is going to create a hell of a lot of cycles, so I prefer to manually delete the list with all the exceptions once error_msgs is done to alleviate this a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually thought about the reference cycle problem -- that's why these are strings and not exception objects -- I don't think there's actually any cycles added by this PR ? unless you're hinting at something I don't know about!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's actually any cycles added by this PR ?

Oh, my bad, I was reading this as keeping the errors in the list instead of the string representation. Maybe renaming errors to error_messages? If you prefer not to do that is fine, I think we can go as it is as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah that would be better -- but then what to call the joined variable 🤔 (to avoid having a variable change type)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the joined variable

final_error_msg ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice that even if it contains the summary of multiple error messages is a single error message at the end.

Maybe you can call it summary_error_msg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went with error_msgs and error_msgs_summary -- thanks for the suggestion!

Copy link
Member
@pablogsal pablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I left a minor nit, tell me what you prefer. We can land it afterwards

@asottile asottile force-pushed the tar_improved_error_message_bpo-8978 branch from befb454 to 873961c Compare April 27, 2021 16:57
@miss-islington
Copy link
Contributor

@asottile: Status check is done, and it's a success ❌ .

@miss-islington
Copy link
Contributor

@asottile: Status check is done, and it's a success ✅ .

@miss-islington
Copy link
Contributor

Sorry, I can't merge this PR. Reason: 2 of 4 required status checks are expected..

@miss-islington
Copy link
Contributor

@asottile: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 9aea31d into python:master Apr 27, 2021
@asottile asottile deleted the tar_improved_error_message_bpo-8978 branch April 27, 2021 17:40
@bedevere-bot
Copy link
bedevere-bot commented Apr 27, 2021

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x SLES 3.x has failed when building commit 9aea31d.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/540/builds/74) and take a look at the build logs.
  4. Check if the failure is related to this commit (9aea31d) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/540/builds/74

Failed tests:

  • test_asyncio

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 12, done.        
remote: Counting objects:  10% (1/10)        
remote: Counting objects:  20% (2/10)        
remote: Counting objects:  30% (3/10)        
remote: Counting objects:  40% (4/10)        
remote: Counting objects:  50% (5/10)        
remote: Counting objects:  60% (6/10)        
remote: Counting objects:  70% (7/10)        
remote: Counting objects:  80% (8/10)        
remote: Counting objects:  90% (9/10)        
remote: Counting objects: 100% (10/10)        
remote: Counting objects: 100% (10/10), done.        
remote: Compressing objects:  16% (1/6)        
remote: Compressing objects:  33% (2/6)        
remote: Compressing objects:  50% (3/6)        
remote: Compressing objects:  66% (4/6)        
remote: Compressing objects:  83% (5/6)        
remote: Compressing objects: 100% (6/6)        
remote: Compressing objects: 100% (6/6), done.        
remote: Total 12 (delta 4), reused 5 (delta 4), pack-reused 2        
From https://github.com/python/cpython
 * branch                  master     -> FETCH_HEAD
Note: switching to '9aea31deddf7458be3546f72185740f3cd06687f'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 9aea31dedd [bpo-8978](https://bugs.python.org/issue8978): improve tarfile.open error message when lzma / bz2 are missing (GH-24850)
Switched to and reset branch 'master'

test_ttk_guionly skipped -- Tk unavailable due to TclError: no display name and no $DISPLAY environment variab [...]
test_startfile skipped -- object <module 'os' from '/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/os.py'> has no attribute 'startfile'
test_tix skipped -- Tk unavailable due to TclError: no display name and no $DISPLAY environment variab [...]
test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run
test_badargs (__main__.GeneralTest) ... ok
test_bound_methods (__main__.GeneralTest) ... ok
test_clear (__main__.GeneralTest) ... ok
test_exit (__main__.GeneralTest) ... ok
test_order (__main__.GeneralTest) ... ok
test_raise (__main__.GeneralTest) ... ok
test_raise_unnormalized (__main__.GeneralTest) ... ok
test_stress (__main__.GeneralTest) ... ok
test_unregister (__main__.GeneralTest) ... ok

----------------------------------------------------------------------
Ran 9 tests in 0.001s

OK
test_winconsoleio skipped -- test only relevant on win32
test_ossaudiodev skipped -- [Errno 2] No such file or directory: '/dev/dsp'
test_devpoll skipped -- test works only on Solaris OS family
test_kqueue skipped -- test works only on BSD
test_nis skipped -- No module named 'nis'
test_msilib skipped -- No module named '_msi'
test_winreg skipped -- No module named 'winreg'
test_tk skipped -- Tk unavailable due to TclError: no display name and no $DISPLAY environment variab [...]
test_ioctl skipped -- Unable to open /dev/tty
test_flock (__main__.FNTLEINTRTest) ... ok
test_lockf (__main__.FNTLEINTRTest) ... ok
test_read (__main__.OSEINTRTest) ... ok
test_wait (__main__.OSEINTRTest) ... ok
test_wait3 (__main__.OSEINTRTest) ... ok
test_wait4 (__main__.OSEINTRTest) ... ok
test_waitpid (__main__.OSEINTRTest) ... ok
test_write (__main__.OSEINTRTest) ... ok
test_devpoll (__main__.SelectEINTRTest) ... skipped 'need select.devpoll'
test_epoll (__main__.SelectEINTRTest) ... ok
test_kqueue (__main__.SelectEINTRTest) ... skipped 'need select.kqueue'
test_poll (__main__.SelectEINTRTest) ... ok
test_select (__main__.SelectEINTRTest) ... ok
test_sigtimedwait (__main__.SignalEINTRTest) ... ok
test_sigwaitinfo (__main__.SignalEINTRTest) ... ok
test_accept (__main__.SocketEINTRTest) ... ok
test_open (__main__.SocketEINTRTest) ... ok
test_os_open (__main__.SocketEINTRTest) ... ok
test_recv (__main__.SocketEINTRTest) ... ok
test_recvmsg (__main__.SocketEINTRTest) ... ok
test_send (__main__.SocketEINTRTest) ... ok
test_sendall (__main__.SocketEINTRTest) ... ok
test_sendmsg (__main__.SocketEINTRTest) ... ok
test_sleep (__main__.TimeEINTRTest) ... ok

----------------------------------------------------------------------
Ran 24 tests in 6.554s

OK (skipped=2)
test_winsound skipped -- No module named 'winsound'
Timeout (0:15:00)!
Thread 0x000003ffa37f8720 (most recent call first):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/selectors.py", line 469 in select
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/asyncio/base_events.py", line 1845 in _run_once
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/asyncio/base_events.py", line 595 in run_forever
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/asyncio/base_events.py", line 628 in run_until_complete
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/test_asyncio/test_subprocess.py", line 177 in test_kill
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/case.py", line 549 in _callTestMethod
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/case.py", line 592 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/case.py", line 652 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/runner.py", line 176 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/support/__init__.py", line 959 in _run_suite
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/support/__init__.py", line 1082 in run_unittest
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 210 in _test_module
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 246 in _runtest_inner2
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 282 in _runtest_inner
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 141 in _runtest
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 194 in runtest
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest_mp.py", line 81 in run_tests_worker
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 661 in _main
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 641 in main
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 719 in main
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/regrtest.py", line 43 in _main
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/regrtest.py", line 47 in <module>
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/runpy.py", line 86 in _run_code
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/runpy.py", line 196 in _run_modul
8000
e_as_main
Timeout (0:15:00)!
Thread 0x000003ff818f8720 (most recent call first):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/selectors.py", line 469 in select
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/asyncio/base_events.py", line 1845 in _run_once
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/asyncio/base_events.py", line 595 in run_forever
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/asyncio/base_events.py", line 628 in run_until_complete
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/test_asyncio/test_subprocess.py", line 190 in test_terminate
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/case.py", line 549 in _callTestMethod
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/case.py", line 592 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/case.py", line 652 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 122 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/suite.py", line 84 in __call__
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/unittest/runner.py", line 176 in run
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/support/__init__.py", line 959 in _run_suite
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/support/__init__.py", line 1082 in run_unittest
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 210 in _test_module
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 246 in _runtest_inner2
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 282 in _runtest_inner
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 154 in _runtest
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/runtest.py", line 194 in runtest
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 321 in rerun_failed_tests
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 698 in _main
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 641 in main
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/libregrtest/main.py", line 719 in main
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/test/__main__.py", line 2 in <module>
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/runpy.py", line 86 in _run_code
  File "/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/Lib/runpy.py", line 196 in _run_module_as_main
make: *** [Makefile:1248: buildbottest] Error 1

Cannot open file '/home/dje/cpython-buildarea/3.x.edelsohn-sles-z/build/test-results.xml' for upload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0