# HG changeset patch # User Gregory Szorc # Date 1604796358 28800 # Node ID 68aedad4c11c346c8da0b131a990d940fa8687e8 # Parent 5c736ba5dc27ef62d46b450c8a2c8b4d3be21cbb pure: guard against empty blocks If blocks is empty, we append `None` to the returned list, which is incorrect. This subtle issue was caught by pytype, which correctly identified the return value as List[Optional[Tuple]] because of this possibility. Differential Revision: https://phab.mercurial-scm.org/D9279 diff -r 5c736ba5dc27 -r 68aedad4c11c mercurial/pure/bdiff.py --- a/mercurial/pure/bdiff.py Mon Nov 16 16:38:57 2020 +0100 +++ b/mercurial/pure/bdiff.py Sat Nov 07 16:45:58 2020 -0800 @@ -51,7 +51,10 @@ shift += 1 r.append((a1, b1, l1 + shift)) prev = a2 + shift, b2 + shift, l2 - shift - r.append(prev) + + if prev is not None: + r.append(prev) + return r