classification
Title: difflib.unified_diff loses context
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.1
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Brice.Videau, terry.reedy
Priority: normal Keywords:

Created on 2011-03-22 10:09 by Brice.Videau, last changed 2011-03-27 21:56 by terry.reedy.

Files
File name Uploaded Description Edit
diff.tgz Brice.Videau, 2011-03-22 10:09
Messages (2)
msg131735 - (view) Author: Brice Videau (Brice.Videau) Date: 2011-03-22 10:09
unified_diff seems to lose the context when comparing the 2 files contained in the attached archive using this script :

import difflib
b1 = open("out1.short","r").read().splitlines(True)
b2 = open("out2.short","r").read().splitlines(True)
compare = difflib.unified_diff(b1,b2)
for line in compare:
    print line,

a big chunk of lines is considered as removed, just to be added next (around line 16).

Comparing out2.short against out1.short does not produce this behavior :
compare = difflib.unified_diff(b2,b1)
is "correct".

Other diff tools such as diff or vimdiff do not exhibit this problem.
msg132368 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-03-27 21:56
2.6 only gets security fixes now.
History
Date User Action Args
2011-03-27 21:56:15terry.reedysetnosy: + terry.reedy

messages: + msg132368
versions: - Python 2.6
2011-03-22 10:09:29Brice.Videaucreate