Skip to content
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

Misleading error message when failing to open file (ex: permission denied) #40

Merged
merged 1 commit into from
May 24, 2018
Merged

Misleading error message when failing to open file (ex: permission denied) #40

merged 1 commit into from
May 24, 2018

Conversation

jeffenstein
Copy link
Contributor

When a .pyc file cannot be opened, this is the error message:

Traceback (most recent call last):
  File "/home/jeff/.local/bin/uncompyle6", line 11, in <module>
    sys.exit(main_bin())
  File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/bin/uncompile.py", line 181, in main_bin
    **options)
  File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 223, in main
    linemap_stream, do_fragments)
  File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 126, in decompile_file
    source_size) = load_module(filename, code_objects)
  File "/home/jeff/.local/lib/python2.7/site-packages/xdis/load.py", line 110, in load_module
    fp.close()
UnboundLocalError: local variable 'fp' referenced before assignment

Changed to use with context handler so that the real exception is raised:

Traceback (most recent call last):
  File "/home/jeff/.local/bin/uncompyle6", line 11, in <module>
    sys.exit(main_bin())
  File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/bin/uncompile.py", line 181, in main_bin
    **options)
  File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 223, in main
    linemap_stream, do_fragments)
  File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 126, in decompile_file
    source_size) = load_module(filename, code_objects)
  File "build/bdist.linux-x86_64/egg/xdis/load.py", line 105, in load_module
IOError: [Errno 13] Permission denied: 'test.pyc'

    Traceback (most recent call last):
      File "/home/jeff/.local/bin/uncompyle6", line 11, in <module>
        sys.exit(main_bin())
      File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/bin/uncompile.py", line 181, in main_bin
        **options)
      File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 223, in main
        linemap_stream, do_fragments)
      File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 126, in decompile_file
        source_size) = load_module(filename, code_objects)
      File "/home/jeff/.local/lib/python2.7/site-packages/xdis/load.py", line 110, in load_module
        fp.close()
    UnboundLocalError: local variable 'fp' referenced before assignment

Changed to use with context handler so that the real exception is raised:

    Traceback (most recent call last):
      File "/home/jeff/.local/bin/uncompyle6", line 11, in <module>
        sys.exit(main_bin())
      File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/bin/uncompile.py", line 181, in main_bin
        **options)
      File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 223, in main
        linemap_stream, do_fragments)
      File "/home/jeff/.local/lib/python2.7/site-packages/uncompyle6/main.py", line 126, in decompile_file
        source_size) = load_module(filename, code_objects)
      File "build/bdist.linux-x86_64/egg/xdis/load.py", line 105, in load_module
    IOError: [Errno 13] Permission denied: 'test.pyc'
@rocky
Copy link
Owner

rocky commented May 24, 2018

Sure. Thanks.

(Note that in the Python 2.4 branch we can't make this change.)

@rocky rocky merged commit 81070dd into rocky:master May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants