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

File read error was not catched. #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jarkko-hautakorpi
Copy link

On some file read errors, the file name is not printed. Like:
Traceback (most recent call last): File "/home/bob/.local/bin/pipreqs", line 8, in <module> sys.exit(main()) File "/home/bob/.local/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 488, in main init(args) File "/home/bob/.local/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 418, in init follow_links=follow_links) File "/home/bob/.local/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 115, in get_all_imports contents = f.read() File "/usr/lib/python3.7/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 65: invalid continuation byte

Including file read inside the Try gives out better message:
ERROR: Failed on file: /home/bob/foofaa/foofaaservice.py Traceback (most recent call last): File "/home/bob/.local/bin/pipreqs", line 8, in <module> sys.exit(main()) File "/home/bob/.local/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 488, in main init(args) File "/home/bob/.local/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 418, in init follow_links=follow_links) File "/home/bob/.local/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 131, in get_all_imports raise exc File "/home/bob/.local/lib/python3.7/site-packages/pipreqs/pipreqs.py", line 116, in get_all_imports contents = f.read() File "/usr/lib/python3.7/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 65: invalid continuation byte

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.

2 participants