You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pylint crashed with a AstroidError and with the following stacktrace:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 782, in _lint_file
check_astroid_module(module)
File "/home/ubuntu/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1052, in check_astroid_module
retval = self._check_astroid_module(
File "/home/ubuntu/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1098, in _check_astroid_module
raw_checker.process_module(node)
File "/home/ubuntu/.local/lib/python3.8/site-packages/pylint/checkers/unicode.py", line 531, in process_module
line = _remove_bom(line, codec)
File "/home/ubuntu/.local/lib/python3.8/site-packages/pylint/checkers/unicode.py", line 223, in _remove_bom
bom = UNICODE_BOMS[encoding]
KeyError: 'utf'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 747, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "/home/ubuntu/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 784, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
Configuration
No response
Command used
pylint main.py
Pylint output
************* Module main
main.py:1:0: C2503: PEP8 recommends UTF-8 as encoding for Python files (bad-file-encoding)
main.py:1:0: F0002: main.py: Fatal error while checking 'main.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in'/home/ubuntu/.cache/pylint/pylint-crash-2022-10-22-01-14-12.txt'. (astroid-error)
Expected behavior
pylint should show the error about the illegal file encoding utf and do not crash
Pierre-Sassoulas
added
Crash 💥
A bug that makes pylint crash
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
and removed
Needs triage 📥
Just created, needs acknowledgment, triage, and proper labelling
labels
Oct 21, 2022
I can work on this over the next couple days. I can also see #7097 didn't add a test, so I can add that. @Pierre-Sassoulas is testing on modules best done via functional tests, or follow the examples in test_self.py which seem to dynamically create a module or load an existing module?
I think I tried to add a test at first in 865b1b8 but it seems I did not manage to reproduce later on (as something was fixed in astroid). So I would say this kind of crash is best tested with mocks in pylint. Due to the nature of the crash we're going to also want to fix astroid and add tests there. Edit: It seems in this issue the error is different and come from pylint (bom = UNICODE_BOMS[encoding] in pylint/checkers/unicode.py) so functional would probably work but there are a lot of unit tests for the unicode checker so the choice is yours,
Bug description
When parsing the following file:
# -*- encoding: utf -*-
pylint crashed with a
AstroidError
and with the following stacktrace:Configuration
No response
Command used
Pylint output
Expected behavior
pylint should show the error about the illegal file encoding
utf
and do not crashPylint version
OS / Environment
Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 20.04 LTS
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: