Skip to content

Commit d1082aa

Browse files
committed
etc: work around utf8 text in rust sources on py3 in featureck
1 parent 4decc40 commit d1082aa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/etc/featureck.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,15 @@
7878
if not filename.endswith(".rs"):
7979
continue
8080

81+
if sys.version_info.major == 2:
82+
_open = lambda f: open(f, 'r')
83+
elif sys.version_info.major == 3:
84+
_open = lambda f: open(f, 'r', encoding="utf-8")
85+
else:
86+
raise RuntimeError("Unsupported python version: %s" % (repr(sys.version_info)))
87+
8188
path = os.path.join(dirpath, filename)
82-
with open(path, 'r') as f:
89+
with _open(path) as f:
8390
line_num = 0
8491
for line in f:
8592
line_num += 1

0 commit comments

Comments
 (0)