The odd part is that I'm not sure how to get difflib to produce a diff that
doesn't start with the three lines:

--- blah
+++ blah
@@ blah

to trigger the bug.  This is clearly unexpected in the code (hence the
UnboundLocalError in the first place) and it it definitely not covered in the
test suite.  Hand crafting a call such as this does not trigger the bug:

$ PYTHONPATH=. python3
>>> from aptdaemon.gtk3widgets import DiffView
>>> dv = DiffView()
>>> dv.show_diff('/etc/passwd', '/etc/group')

Without a test, a fix is mostly just conjecture.  I think the best thing
to do is to set `line_number = 0` outside the loop.  This might give you
nonsense but it'll avoid a crash.  I thought about setting it to None
outside the loop, but then the += will still crash, just with a
different one (perhaps we should force that and output some debugging to
better see what's happening, but otoh is it worth it?)

I will attach a branch momentarily.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1120322

Title:
  update-manager crashed with UnboundLocalError in show_diff(): local
  variable 'line_number' referenced before assignment

To manage notifications about this bug go to:
https://bugs.launchpad.net/aptdaemon/+bug/1120322/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to