python-unidiff icon indicating copy to clipboard operation
python-unidiff copied to clipboard

unidiff.errors.UnidiffParseError: Unexpected hunk found: @@ -2,6 +2,6 @@

Open bernd-wechner opened this issue 1 year ago • 2 comments

I am writing diff files using Python's difflib.unified_diff();

One such file commences with:

--- 
+++ 
@@ -2,6 +2,6 @@

if I try to read it then unidiff fails with:

unidiff.errors.UnidiffParseError: Unexpected hunk found: @@ -2,6 +2,6 @@

I am left suspecting, when comparing it with the README samples that the missing filename is bothering it. If so, it shouldn't really given that difflib.unified_diff() produces output that lacks it.

bernd-wechner avatar Dec 04 '23 02:12 bernd-wechner

Manually adding a filename as in:

--- test1
+++ test2
@@ -2,6 +2,6 @@

sees it loaded fine. Looks like I'll have to ask difflib to write those filenames out. All good I guess, though I can't help but feel as they are optional in difflib, they should rightly be optional in unidiff too. But that of course is a matter of opinion.

bernd-wechner avatar Dec 04 '23 02:12 bernd-wechner

+1 i also have this issue

nsbradford avatar Feb 08 '24 23:02 nsbradford