From 77aa0e766e85baaf8b2915675809c221f5f88a20 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 27 Oct 2024 02:47:11 +0100 Subject: Don’t crash on corrupt history MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yahoozy.py | 7 +++++-- 1 file 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 -- cgit v1.2.3