Unchanged lines detected as changes with difflib.HtmlDiff
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
When running HtmlDiff on test_api_result.response.txt test_api_result.expected.txt (reported at https://github.com/jeffkaufman/icdiff/issues/223) unchanged lines are being detected as changes. Here's the setup:
import difflib
a = open("test_api_result.response.txt").readlines()
b = open("test_api_result.expected.txt").readlines()
with open("tmp.html", "w") as outf:
outf.write(difflib.HtmlDiff().make_file(a,b))
And the results: https://www.jefftk.com/html-diff-output-repro
I don't see these spurious deltas when running diff:
$ diff test_api_result.*
31,32c31,32
< 'latitude': 1,
< 'longitude': 1,
---
> 'latitude': 1.0,
> 'longitude': 1.0,
40c40
< 'meeting_url': '',
---
> 'meeting_url': None,
77,78c77,78
< 'latitude': 1,
< 'longitude': 1,
---
> 'latitude': 1.0,
> 'longitude': 1.0,
86c86
< 'meeting_url': '',
---
> 'meeting_url': None,
...
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the report with test_api_result.response.txt and test_api_result.expected.txt, then inspect the HtmlDiff output at the provided reproduction page and compare it with diff. The work is done when unchanged lines are no longer marked as changes while the actual differences remain visible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100