diff options
author | Anthony Sottile <asottile@umich.edu> | 2021-01-07 10:35:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 10:35:38 -0800 |
commit | c47f5c1f977c20f16c19bc282834c70c9b40d800 (patch) | |
tree | 7d1d06576276b9a20bdcba7104c552218d069a62 /pycodestyle.py | |
parent | 9dd78b97dea0e943300c92c853d6869e7fe41299 (diff) | |
parent | dde53f69f11571161c1db7c43ebfc3cfdfcc6f96 (diff) | |
download | pep8-c47f5c1f977c20f16c19bc282834c70c9b40d800.tar.gz |
Merge pull request #976 from asottile/crlf_at_beginning_of_file
use tokenize.open to avoid incorrect line endings at beginning of file
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-x | pycodestyle.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 17fac7a..2f4313f 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1814,10 +1814,8 @@ else: def readlines(filename): """Read the source code.""" try: - with open(filename, 'rb') as f: - (coding, lines) = tokenize.detect_encoding(f.readline) - f = TextIOWrapper(f, coding, line_buffering=True) - return [line.decode(coding) for line in lines] + f.readlines() + with tokenize.open(filename) as f: + return f.readlines() except (LookupError, SyntaxError, UnicodeError): # Fall back if file encoding is improperly declared with open(filename, encoding='latin-1') as f: |