Source

subvertpy-patches / assert.diff

# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
# Date 1284483682 -7200
# Node ID f223a3e079a3d1b5f840612823f0b27448a2b6f0
# Parent  fccc2c9505d623eff33e4a54457d8e5c3a550d5c
Rather than raising an AssertionError, assert.

Asserting is appropriate here, as the check primarily functions as an
internal consistency check against clients of Subvertpy. Some end-user
software runs in -O mode, disabling assertions.

diff --git a/subvertpy/delta.py b/subvertpy/delta.py
--- a/subvertpy/delta.py
+++ b/subvertpy/delta.py
@@ -42,8 +42,7 @@ def apply_txdelta_window(sbuf, window):
     (sview_offset, sview_len, tview_len, src_ops, ops, new_data) = window
     sview = sbuf[sview_offset:sview_offset+sview_len]
     tview = txdelta_apply_ops(src_ops, ops, new_data, sview)
-    if len(tview) != tview_len:
-        raise AssertionError("%d != %d" % (len(tview), tview_len))
+    assert len(tview) == tview_len, "%d != %d" % (len(tview), tview_len)
     return tview