In #118150, the docs were rewritten to mention autojunk and its trade-offs more prominently.
I don't think there's more to do for this issue, short of adding a better algorithm and/or changing defaults (which would bring backwards compatibility issues).
Activity
cdanis commented on May 19, 2020
When difflib.unified_diff is asked to produce a diff of inputs a.txt and b.txt (attached), with 10 context lines, it produces the following:
However, this could simply and much more readably be rendered as:
(This is what diff -u10 produces.)
WeiHao97 commented on Jun 2, 2022
Hi @ezio-melotti @DahlitzFlorian, @cdanis, I have encountered the same problem when using the function. Is this solved ? Thank you
noscript commented on Nov 16, 2022
The fix is simple, disable autojunk:
cpython/Lib/difflib.py
Line 1138 in 0a208d5
encukou commented on Sep 7, 2026
In #118150, the docs were rewritten to mention autojunk and its trade-offs more prominently.
I don't think there's more to do for this issue, short of adding a better algorithm and/or changing defaults (which would bring backwards compatibility issues).
force unified_diff to accept autojunk=False