Fix infinite loop when handling utf-8
This commit is contained in:
parent
c2fa394e7a
commit
1f14ef7747
1 changed files with 5 additions and 1 deletions
|
@ -286,7 +286,11 @@ def get_problem_case(problem, files):
|
||||||
s.decode('utf-8')
|
s.decode('utf-8')
|
||||||
break
|
break
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
s += f.read(1)
|
next_char = f.read(1)
|
||||||
|
if next_char:
|
||||||
|
s += next_char
|
||||||
|
else:
|
||||||
|
raise Exception('File %s is not able to decode in utf-8' % file)
|
||||||
qs = get_visible_content(s)
|
qs = get_visible_content(s)
|
||||||
cache.set(cache_key, qs, 86400)
|
cache.set(cache_key, qs, 86400)
|
||||||
result[file] = qs
|
result[file] = qs
|
||||||
|
|
Loading…
Reference in a new issue