From 1d38f872e0aee83713b94b96a7c810719243ac38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sun, 22 Jun 2025 23:15:16 +0100 Subject: [PATCH] fix: Convert assertion to ApplyDeltaError in apply_delta function apply_delta was raising AssertionError instead of ApplyDeltaError in the pure Python implementation when the Rust extension was not available. Fixes #1606 --- NEWS | 6 ++++++ dulwich/pack.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dulwich/pack.py b/dulwich/pack.py index a12830a59..2f1c35e07 100644 --- a/dulwich/pack.py +++ b/dulwich/pack.py @@ -2516,7 +2516,10 @@ def get_delta_header_size(delta, index): src_size, index = get_delta_header_size(delta, index) dest_size, index = get_delta_header_size(delta, index) - assert src_size == len(src_buf), f"{src_size} vs {len(src_buf)}" + if src_size != len(src_buf): + raise ApplyDeltaError( + f"Unexpected source buffer size: {src_size} vs {len(src_buf)}" + ) while index < delta_length: cmd = ord(delta[index : index + 1]) index += 1