Skip to content

HtmlDiff.make_table raises RecursionError when wrapping long lines at column 1 #158704

Description

@augusto-rehfeldt

Bug report

Bug description:

Documented behaviour: HtmlDiff.make_table documentation: "Compares fromlines and tolines (lists of strings) and returns a string which is a complete HTML table containing a side by side, line by line comparison with change highlights." HtmlDiff constructor documentation: "wrapcolumn -- column number where lines are broken and wrapped, defaults to None where lines are not wrapped."

Expected: Return an HTML table string with the identical lines wrapped at column 1.

Actual: Raises RecursionError: maximum recursion depth exceeded.

import difflib

s = "a" * 999
expected = "HTML table string (no exception)"
if not (s and s.isascii() and s.isalpha()):
    print("REFUTATION REJECTED: invalid input")
else:
    try:
        result = difflib.HtmlDiff(wrapcolumn=1).make_table([s], [s])
        valid = isinstance(result, str) and "<table" in result and "</table>" in result
        actual = expected if valid else repr(result)
    except Exception as e:
        valid = False
        actual = f"{type(e).__name__}: {e}"
    if valid:
        print("REFUTATION REJECTED: documented HTML table returned")
    else:
        print("REFUTATION CONFIRMED:", repr(s), "actual:", actual, "expected:", expected)

Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library difflib:

REFUTATION CONFIRMED: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' actual: RecursionError: maximum recursion depth exceeded expected: HTML table string (no exception)

This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/difflib-20261003-082046-c2

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions