diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2016-04-03 11:44:11 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-04-03 14:02:13 +0300 |
| commit | 38f6bd2195fe04515d15165c44366d0791581493 (patch) | |
| tree | f74f564e00077c03e94f0524230b19fc1893ece3 | |
| parent | 42c6882061907e4324a561bcb15163609bb29348 (diff) | |
| download | pylint-git-38f6bd2195fe04515d15165c44366d0791581493.tar.gz | |
config files with BOM markers can now be read.
Close #864.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | pylint/checkers/typecheck.py | 2 | ||||
| -rw-r--r-- | pylint/config.py | 7 | ||||
| -rw-r--r-- | pylint/test/regrtest_data/.pylintrc | 4 | ||||
| -rw-r--r-- | pylint/test/regrtest_data/meta.py | 3 | ||||
| -rw-r--r-- | pylint/test/test_self.py | 7 |
6 files changed, 25 insertions, 2 deletions
@@ -2,6 +2,10 @@ ChangeLog for Pylint -------------------- -- + * config files with BOM markers can now be read. + + Close #864. + * epylint.py_run does not crash on big files, using .communicate() instead of .wait() Close #599 diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 8d12039bd..f9ab34558 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -310,7 +310,7 @@ accessed. Python regular expressions are accepted.'} # (surrounded by quote `"` and followed by a comma `,`) # REQUEST,aq_parent,"[a-zA-Z]+_set{1,2}"' => # ('REQUEST', 'aq_parent', '[a-zA-Z]+_set{1,2}') - if isinstance(self.config.generated_members, str): + if isinstance(self.config.generated_members, six.string_types): gen = shlex.shlex(self.config.generated_members) gen.whitespace += ',' gen.wordchars += '[]-+' diff --git a/pylint/config.py b/pylint/config.py index 2ef658377..1a29a119f 100644 --- a/pylint/config.py +++ b/pylint/config.py @@ -28,6 +28,7 @@ from __future__ import print_function import contextlib import collections import copy +import io import optparse import os import pickle @@ -616,7 +617,11 @@ class OptionsManagerMixIn(object): config_file = os.path.expanduser(config_file) if config_file and os.path.exists(config_file): parser = self.cfgfile_parser - parser.read([config_file]) + + # Use this encoding in order to strip the BOM marker, if any. + with io.open(config_file, 'r', encoding='utf_8_sig') as fp: + parser.readfp(fp) + # normalize sections'title for sect, values in list(parser._sections.items()): if not sect.isupper() and values: diff --git a/pylint/test/regrtest_data/.pylintrc b/pylint/test/regrtest_data/.pylintrc new file mode 100644 index 000000000..9a5bb5a44 --- /dev/null +++ b/pylint/test/regrtest_data/.pylintrc @@ -0,0 +1,4 @@ +[MASTER] + +optimize-ast=no + diff --git a/pylint/test/regrtest_data/meta.py b/pylint/test/regrtest_data/meta.py new file mode 100644 index 000000000..700120727 --- /dev/null +++ b/pylint/test/regrtest_data/meta.py @@ -0,0 +1,3 @@ +# pylint: disable=invalid-name, missing-docstring +# pylint: disable=unbalanced-tuple-unpacking +n = 42 diff --git a/pylint/test/test_self.py b/pylint/test/test_self.py index 9a23cc039..76d691c50 100644 --- a/pylint/test/test_self.py +++ b/pylint/test/test_self.py @@ -347,6 +347,13 @@ class RunTC(unittest.TestCase): self._test_output([path, "--confidence=HIGH,INFERENCE"], expected_output=expected) + def test_bom_marker(self): + path = join(HERE, 'regrtest_data', 'meta.py') + config_path = join(HERE, 'regrtest_data', '.pylintrc') + expected = 'Your code has been rated at 10.00/10' + self._test_output([path, "--rcfile=%s" % config_path], + expected_output=expected) + if __name__ == '__main__': unittest.main() |
