Skip to content

Commit

Permalink
Merge pull request #543 from vidartf/limit-stream-diff
Browse files Browse the repository at this point in the history
Limit the size of stream outputs to diff
  • Loading branch information
vidartf committed Sep 29, 2020
2 parents 141b2dc + 598c072 commit b707946
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nbdime/diffing/notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
re_pointer = re.compile(r"0x[a-f0-9]{8,16}", re.IGNORECASE)

TEXT_MIMEDATA_MAX_COMPARE_LENGTH = 10000
STREAM_MAX_COMPARE_LENGTH = 1000


# List of mimes we can diff recursively
Expand Down Expand Up @@ -139,7 +140,7 @@ def _compare_mimedata(mimetype, x, y, comp_text, comp_base64):
# TODO: Compare binary images?
#if mimetype.startswith("image/"):
if isinstance(x, string_types) and isinstance(y, string_types):
_compare_mimedata_strings(x, y, comp_text, comp_base64)
return _compare_mimedata_strings(x, y, comp_text, comp_base64)
# Fallback to exactly equal
return x == y

Expand Down Expand Up @@ -228,7 +229,7 @@ def compare_output_approximate(x, y):
if ot == "stream":
if x["name"] != y["name"]:
return False
if not compare_strings_approximate(x["text"], y["text"]):
if not compare_strings_approximate(x["text"], y["text"], maxlen=STREAM_MAX_COMPARE_LENGTH):
return False
handled.update(("name", "text"))

Expand Down

0 comments on commit b707946

Please sign in to comment.