[issue11747] unified_diff function product incorrect range information

ysj.ray report at bugs.python.org
Tue Apr 5 10:01:18 CEST 2011


ysj.ray <ysj.ray at gmail.com> added the comment:

Since if one of the two comparing files is empty, gnu diff regards the beginning line of differences as line 0 (there is not any lines), but difflib regards it as line 1(there is a line, but empty). Not sure weather is correct since the practice usage of diff output is feeding it to "patch" program which determine the different line location mostly based on context identical lines instead of the line numbers in the hunk headers, so it doesn't matter weather it's line 0 or line 1. But it is still better to keep consist with gnu diff.

In context_diff() it is correct since if there is less then 2 different lines in a hunk, only ending line number is display in hunk header.

Here is a patch which fix this.

----------
keywords: +patch
nosy: +ysj.ray
type:  -> behavior
versions: +Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file21539/issue_11747.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11747>
_______________________________________


More information about the Python-bugs-list mailing list