diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-10-27 02:47:11 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-10-27 02:47:19 +0100 |
commit | 77aa0e766e85baaf8b2915675809c221f5f88a20 (patch) | |
tree | 99a015f9722924998691cccf24ccf47483842c15 | |
parent | 35b4121a2529dde3f156db55559b2ac502757ae1 (diff) |
Don’t crash on corrupt history
-rwxr-xr-x | yahoozy.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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 |