[New-bugs-announce] [issue11632] difflib.unified_diff loses context

Brice Videau report at bugs.python.org
Tue Mar 22 11:09:30 CET 2011

New submission from Brice Videau <brice.videau at gmail.com>:

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.

components: Library (Lib)
files: diff.tgz
messages: 131735
nosy: Brice.Videau
priority: normal
severity: normal
status: open
title: difflib.unified_diff loses context
type: behavior
versions: Python 2.6, Python 3.1
Added file: http://bugs.python.org/file21332/diff.tgz

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list