Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#3725 closed defect (fixed)

unified_diff() fails when there are fewer lines than the context

Reported by: bjourne@… Owned by: Matthew Good
Priority: normal Milestone: 0.10.1
Component: version control Version: devel
Severity: minor Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

>>> from trac.versioncontrol.diff import unified_diff
>>> list(unified_diff(['old'], ['new']))
Traceback (most recent call last):
  File "stealtrac.py", line 122, in ?
    list(unified_diff(['old'], ['new']))
  File "/usr/lib/python2.4/site-packages/trac/versioncontrol/diff.py", line 217, in unified_diff
    i1, i2, j1, j2 = group[0][1], group[-1][2], group[0][3], group[-1][4]
TypeError: unsubscriptable object

I have also created a unit test for this.

Attachments (1)

unittest-against-bug-in-unified_diff.patch (2.0 KB ) - added by bjourne@… 18 years ago.
Add a new test suite

Download all attachments as: .zip

Change History (4)

by bjourne@…, 18 years ago

Add a new test suite

comment:1 by Matthew Good, 18 years ago

Milestone: 0.10.1
Owner: changed from Jonas Borgström to Matthew Good
Severity: normalminor
Summary: Bug in diff.unified_diff()unified_diff() fails when there are fewer lines than the context

Ok, it appears that the error occurs when there are fewer lines to diff than the expected "context" lines surrounding the diff. This doesn't seem to impact many people, so I'll try to get this fixed for 0.10.1.

comment:2 by Matthew Good, 18 years ago

Component: generalversion control

comment:3 by Matthew Good, 18 years ago

Resolution: fixed
Status: newclosed

Actually the problem was the item yielded from _group_opcodes was a generator instead of a list when the context was None. Fixed in r3973 and r3974.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Matthew Good.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Matthew Good to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.