[ python-Bugs-1054821 ] difflib HtmlDiff() extra space on inserted 1 character lines

SourceForge.net noreply at sourceforge.net
Tue Oct 26 21:44:25 CEST 2004


Bugs item #1054821, was opened at 2004-10-26 14:44
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1054821&group_id=5470

Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Dan Gass (dmgass)
Assigned to: Nobody/Anonymous (nobody)
Summary: difflib HtmlDiff() extra space on inserted 1 character lines

Initial Comment:
difflib.py -- rev 1.27
class - HtmlDiff
method - _make_line
line numbers 1370 thru 1371

was:
            if len(text) <= 1:
                text = ' '+text
should be:
            if not text:
                text = ' '

This code was intended to show an "add" highlight in
the case of inserted blank lines.  It was originally
coded to look for lines of length 1 or less to
accomodate lines where the newline character is not
stripped off.  The undesired effect is that lines
containing only one character (such as a open or close
{} for a 'c' function) that are in column zero get
represented with a space infront of it.  

Since newlines are stripped before this code is
executed (a code change done after this logic was
written) the above fix eliminates the undesired effect
without sacrificing anything.

The test for this module will not break as a result of
this change.  If it is desired, I can modify the test
to cover this code.  It would involve adding a blank
line and possibly a one character line to the test
input and then rebaselining the output.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1054821&group_id=5470


More information about the Python-bugs-list mailing list