summaryrefslogtreecommitdiff
path: root/pycodestyle.py
diff options
context:
space:
mode:
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-xpycodestyle.py6
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: