diff cutils/treesum.py @ 375:7044c2900890

FIX: Convert the ultimate parse errors for a .treesum file into a real ValueError. Do not assert such important runtime errors. BUGS: Should be a dedicated exception type.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 05 May 2025 09:21:55 +0200
parents bfe1160fbfd3
children 6b327893a9c3
line wrap: on
line diff
--- a/cutils/treesum.py	Mon May 05 08:53:35 2025 +0200
+++ b/cutils/treesum.py	Mon May 05 09:21:55 2025 +0200
@@ -1870,7 +1870,8 @@
                         else:
                             return (algo_name, mo.group(2), None, None)
                     else:
-                        assert False, line
+                        raise ValueError(
+                            "Cannot parse line: %r" % (line,))
         return line
 
     def _get_next_line(self):
@@ -1932,7 +1933,9 @@
             block_no = 0
             for record in reader:
                 if record[0] == "VERSION":
-                    assert record[1] == "1"
+                    if record[1] != "1":
+                        raise ValueError(
+                            "VERSION not yet handled: %r" % (record[1],))
                     # start a new block
                     in_block = True
                     block_no += 1