Skip to content

Limit the size of stream outputs to diff #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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