Skip to content

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

Closed
@MuellerSeb

Description

@MuellerSeb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crash 💥A bug that makes pylint crash

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions