Skip to content

Commit b611568

Browse files
committed
exception in decoding utf
1 parent 1a0c3ef commit b611568

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python150k/preprocess.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@ def collect_data(filename: str,
182182
stdout=DEVNULL, stderr=STDOUT)
183183
print("Building AST tree from a filename:", filename)
184184

185-
code = read_file_to_string(filename)
185+
try:
186+
code = read_file_to_string(filename)
187+
except:
188+
print("File with bad encoding:", filename)
189+
error_counter += 1
190+
is_appropriate = False
191+
return None, is_appropriate
186192

187193
# let's replace tabs for spaces in the future
188194
code = re.sub('\t', ' ' * 4, code)

0 commit comments

Comments
 (0)