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

unidiff.errors.UnidiffParseError seen with v0.7.1

Open marxin opened this issue 3 years ago • 5 comments

I see the following regression starting with fd58ddcf849ed6885e3d096db3a7200e0b84705e:

/tmp/venv/bin/python -c 'import unidiff; unidiff.PatchSet.from_filename("test.patch.txt")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/marxin/Programming/python-unidiff/unidiff/patch.py", line 591, in from_filename
    instance = cls(f)
  File "/home/marxin/Programming/python-unidiff/unidiff/patch.py", line 454, in __init__
    self._parse(data, encoding=encoding, metadata_only=metadata_only)
  File "/home/marxin/Programming/python-unidiff/unidiff/patch.py", line 506, in _parse
    raise UnidiffParseError('Unexpected new file found: %s' % line)
unidiff.errors.UnidiffParseError: Unexpected new file found: new file mode 100644

test.patch.txt

marxin avatar Jan 28 '22 02:01 marxin

Looks like the regular expression to parse git diff header does not consider quotes

https://github.com/matiasb/python-unidiff/blob/v0.7.1/unidiff/constants.py#L40

yan12125 avatar Jan 28 '22 12:01 yan12125

@Felixoid

marxin avatar Jan 28 '22 12:01 marxin

Right, none of the regexes is considering the quotes (not a new issue, but with the changes parsing the git diff header the given diff breaks). #90 will fix the parsing so this works, but quotes support will need to be worked out later.

matiasb avatar Jan 28 '22 15:01 matiasb

Thanks, version 0.7.2 works great!

yan12125 avatar Jan 28 '22 16:01 yan12125

Thanks, I can confirm it works for me now.

marxin avatar Jan 28 '22 16:01 marxin