diff options
author | Martin Možina <martin.mozina@fri.uni-lj.si> | 2018-05-20 18:13:48 +0200 |
---|---|---|
committer | Martin Možina <martin.mozina@fri.uni-lj.si> | 2018-05-20 18:13:48 +0200 |
commit | 2678fc027f891ffafb31e5fd411342034c7362e5 (patch) | |
tree | f16adad2f81ae045216d9f74103f3ff74c85ea0e | |
parent | 8723bd7cd2d227634d67f24e9514d88e9f1c73a7 (diff) |
Catch exception when files have non-utf characters.
-rw-r--r-- | main.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -24,8 +24,10 @@ def get_programs(path: str, names: str, do_canonicalize: bool = False): for submission in os.listdir(user_dir): with open(os.path.join(user_dir, submission), 'r') as f: - code = f.read().strip() - + try: + code = f.read().strip() + except: + continue # skip syntactically incorrect programs try: ast.parse(code) |