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

PyLint Fails when there are non-ascii characters in setup.cfg #4328

Closed
MuellerSeb opened this issue Apr 9, 2021 · 2 comments · Fixed by #4329
Closed

PyLint Fails when there are non-ascii characters in setup.cfg #4328

MuellerSeb opened this issue Apr 9, 2021 · 2 comments · Fixed by #4329
Labels
Crash 💥 A bug that makes pylint crash
Milestone

Comments

@MuellerSeb
Copy link
Contributor

MuellerSeb commented Apr 9, 2021

Hi there,

I get the following error, when running pylint from spyder (on a single file):

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.6/dist-packages/pylint/__main__.py", line 18, in <module>
    pylint.run_pylint()
  File "/usr/local/lib/python3.6/dist-packages/pylint/__init__.py", line 19, in run_pylint
    from pylint.lint import Run as PylintRun
  File "/usr/local/lib/python3.6/dist-packages/pylint/lint/__init__.py", line 76, in <module>
    from pylint.lint.pylinter import PyLinter
  File "/usr/local/lib/python3.6/dist-packages/pylint/lint/pylinter.py", line 19, in <module>
    from pylint import checkers, config, exceptions, interfaces, reporters
  File "/usr/local/lib/python3.6/dist-packages/pylint/checkers/__init__.py", line 45, in <module>
    from pylint.checkers.base_checker import BaseChecker, BaseTokenChecker
  File "/usr/local/lib/python3.6/dist-packages/pylint/checkers/base_checker.py", line 20, in <module>
    from pylint.config import OptionsProviderMixIn
  File "/usr/local/lib/python3.6/dist-packages/pylint/config/__init__.py", line 103, in <module>
    PYLINTRC = find_pylintrc()
  File "/usr/local/lib/python3.6/dist-packages/pylint/config/__init__.py", line 96, in find_pylintrc
    for config_file in find_default_config_files():
  File "/usr/local/lib/python3.6/dist-packages/pylint/config/find_default_config_files.py", line 35, in find_default_config_files
    if config_name.endswith(".cfg") and not _cfg_has_config(config_name):
  File "/usr/local/lib/python3.6/dist-packages/pylint/config/find_default_config_files.py", line 23, in _cfg_has_config
    parser.read(path)
  File "/usr/lib/python3.6/configparser.py", line 697, in read
    self._read(fp, filename)
  File "/usr/lib/python3.6/configparser.py", line 1015, in _read
    for lineno, line in enumerate(fp, start=1):
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 227: ordinal not in range(128)

Changing this line:
https://github.com/PyCQA/pylint/blob/5e1928b325bc798f5be1ab94031bf6816d058d9f/pylint/config/find_default_config_files.py#L29
to

parser.read(path, encoding='utf-8')

makes it at least working. I don't know the rational behind this or how to force pylint to read setup.cfg encoded as utf-8. Putting # -*- coding: utf-8 -*- on top of the file didn't help. Or should I prevent umlauts in setup.cfg?!

Am I missing something?

Cheers,
Sebastian

@Pierre-Sassoulas
Copy link
Member

Thank you for the report, yes the encoding should be defined to utf8 in pylint/pylint/config/find_default_config_files.py, do you want to fix this yourself ?

@Pierre-Sassoulas Pierre-Sassoulas added the Crash 💥 A bug that makes pylint crash label Apr 9, 2021
@MuellerSeb
Copy link
Contributor Author

@Pierre-Sassoulas see #4329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants