Skip to content
Snippets Groups Projects
Commit b2666e767029 authored by Matt Harbison's avatar Matt Harbison
Browse files

cffi: adjust the list returned by bdiff.blocks to never have a None entry

This was flagged by pytype after merging the corresponding bdiff.pyi in cext:

    File ".../mercurial/cffi/bdiff.py", line 44, in blocks: bad return type [bad-return-type]
               Expected: List[Tuple[int, int, int, int]]
      Actually returned: List[None]

AFAICT, all callers immediately unpack the tuple into 4 variables, so a `None`
entry would simply crash if they aren't all overwritten.  As long a `count` and
the link list are consistent, this shouldn't be a problem.

This placates both pytype and PyCharm (which complained about the `i` in `rl[i]`
having the wrong type with the old code).
parent b8389533ba3a
No related branches found
No related tags found
2 merge requests!485branching: merge default into stable,!295typing: small fixes to cext and pure
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
count = lib.bdiff_diff(a[0], an, b[0], bn, l) count = lib.bdiff_diff(a[0], an, b[0], bn, l)
if count < 0: if count < 0:
raise MemoryError raise MemoryError
rl = [None] * count rl = [(0, 0, 0, 0)] * count
h = l.next h = l.next
i = 0 i = 0
while h: while h:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment