Skip to content

Commit

Permalink
cliutils: archive_viewer: fix crash when quitting or moving up a level
Browse files Browse the repository at this point in the history
Calling arch.lib.close() when cleaning up the archive when either
moving up a level or quitting the archive_viewer application
triggers the assert in pyimod02_archive.ArchiveFile.__getattr__.

This is because local file object is set only between __enter__
and __exit__ calls, i.e., while in the `with arch.lib:` block.
Which also means that there's no need for attempting to close
those file handles in the first place, and the error is probably
a regression from when the thread-local file objects were
introduced.
  • Loading branch information
rokm committed Feb 18, 2021
1 parent 289628a commit 81ecf66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 0 additions & 3 deletions PyInstaller/utils/cliutils/archive_viewer.py
Expand Up @@ -65,7 +65,6 @@ def main(name, brief, debug, rec_debug, **unused_options):
if cmd == 'U':
if len(stack) > 1:
arch = stack[-1][1]
arch.lib.close()
del stack[-1]
name, arch = stack[-1]
show(name, arch)
Expand Down Expand Up @@ -106,8 +105,6 @@ def main(name, brief, debug, rec_debug, **unused_options):

def do_cleanup():
global stack, cleanup
for (name, arch) in stack:
arch.lib.close()
stack = []
for filename in cleanup:
try:
Expand Down
2 changes: 2 additions & 0 deletions news/5554.bugfix.rst
@@ -0,0 +1,2 @@
Fix a crash in ``pyi-archive_viewer`` when quitting the application or
moving up a level.

0 comments on commit 81ecf66

Please sign in to comment.