aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2018-10-05 16:14:51 +0200
committerDaniel Hahler <git@thequod.de>2018-10-05 23:13:44 +0200
commit2351b931dd1b3ca0c83b1d684d5a62ba90f9f280 (patch)
tree3daa8964913e101a3c799a242b25d99c9e09a077
parent39ad99b594aa68b6c3024dd9bfa3f7e31c14dff9 (diff)
downloadrneovim-2351b931dd1b3ca0c83b1d684d5a62ba90f9f280.tar.gz
rneovim-2351b931dd1b3ca0c83b1d684d5a62ba90f9f280.tar.bz2
rneovim-2351b931dd1b3ca0c83b1d684d5a62ba90f9f280.zip
clint: use fileinput for stdin
Fixes handing of "-" on Python 3: Traceback (most recent call last): File "…/Vcs/neovim/src/clint.py", line 3625, in <module> main() File "…/Vcs/neovim/src/clint.py", line 3618, in main ProcessFile(filename, _cpplint_state.verbose_level) File "…/Vcs/neovim/src/clint.py", line 3464, in ProcessFile 'replace').read().split('\n') File "/usr/lib/python3.7/codecs.py", line 701, in read return self.reader.read(size) File "/usr/lib/python3.7/codecs.py", line 500, in read data = self.bytebuffer + newdata TypeError: can't concat str to bytes
-rwxr-xr-xsrc/clint.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/clint.py b/src/clint.py
index 9fd93ce143..cb08b52dc6 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -49,6 +49,7 @@ from __future__ import unicode_literals
import codecs
import copy
+import fileinput
import getopt
import math # for log
import os
@@ -3456,10 +3457,10 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]):
# is processed.
if filename == '-':
- lines = codecs.StreamReaderWriter(sys.stdin,
- codecs.getreader('utf8'),
- codecs.getwriter('utf8'),
- 'replace').read().split('\n')
+ stdin = sys.stdin.read()
+ if sys.version_info < (3, 0):
+ stdin = stdin.decode('utf8')
+ lines = stdin.split('\n')
else:
lines = codecs.open(
filename, 'r', 'utf8', 'replace').read().split('\n')