Skip to content

Commit a4a80de

Browse files
committed
unify all exceptions
1 parent f280273 commit a4a80de

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

python150k/preprocess.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def get_tokens(code: str) -> Tuple[list, int, list]:
130130
tokens.append(token.string)
131131
else:
132132
stopwords_count += 1
133-
except tokenize.TokenError:
133+
except:
134134
is_tokenizable = False
135135
return None, None, comments, docstring, stopwords_count, is_tokenizable
136136
return code, tokens, comments, docstring, stopwords_count, is_tokenizable
@@ -178,7 +178,7 @@ def collect_data(filename: str,
178178

179179
# Convert Python 2 to Python 3
180180
# os.system(f"~/anaconda3/envs/scs/bin/2to3 {filename} -w -n")
181-
run(["/home/masaidov/.conda/envs/scs/bin/2to3", filename, "-w", "-n"],
181+
run(["/home/marat/.pyenv/shims/2to3", filename, "-w", "-n"],
182182
stdout=DEVNULL, stderr=STDOUT)
183183
print("Building AST tree from a filename:", filename)
184184

@@ -330,12 +330,8 @@ def convert_tokens_to_ast(functions):
330330
try:
331331
ast_fun_tokens = json.loads(parse_python3.parse_file(function, "code"))
332332
ast_fun_sequential = get_dfs(convert(ast_fun_tokens))
333-
except SyntaxError:
334-
print("Met syntax problem.")
335-
error_counter += 1
336-
continue
337-
except TypeError:
338-
print("JSON is not serializable.")
333+
except:
334+
print("Met syntax or type error.")
339335
error_counter += 1
340336
continue
341337
ast_tokens.append(ast_fun_sequential)

0 commit comments

Comments
 (0)