aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-27 02:47:11 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-10-27 02:47:19 +0100
commit77aa0e766e85baaf8b2915675809c221f5f88a20 (patch)
tree99a015f9722924998691cccf24ccf47483842c15
parent35b4121a2529dde3f156db55559b2ac502757ae1 (diff)
Don’t crash on corrupt history
-rwxr-xr-xyahoozy.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/yahoozy.py b/yahoozy.py
index 62b5478..c82a864 100755
--- a/yahoozy.py
+++ b/yahoozy.py
@@ -823,8 +823,11 @@ def loadhist(fp: TextIO, n: int = -1) -> list[LBEntry]:
for i in itertools.count():
if i == n or (line := fp.readline()) == "":
break
- score, name = line.rstrip("\n").split("\x1F")
- xs.append((int(score), name))
+ try:
+ score, name = line.rstrip("\n").split("\x1F")
+ xs.append((int(score), name))
+ except (TypeError, ValueError):
+ pass # Corrupt entry
return xs