Found it! Here's the problem: in Python 3, the targets of except clauses are deleted from the current namespace after the exception is handled. This is so the circular references created during the exception handling are eliminated. This is detailed in the Python 3 language reference: http://docs.python.org/3/reference/compound_stmts.html#except
The tricky thing here is that `e = None` set before the try/except doesn't help because if one of the excepts get triggered, the equivalent of `del e` is executed, which removes it from the namespace and causes the UnboundLocalError. FWIW, the `del e` behavior does not occur in Python 2, so this wouldn't crash. It's certainly an odd corner case of the language. The fix is to use a different name to capture the exception for later printing than is used in the except clause. Should be an easy fix and I'll update trunk. Attached is a boiled down example. ** Attachment added: "foo.py" https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1102593/+attachment/3647737/+files/foo.py ** Changed in: ubuntu-release-upgrader (Ubuntu) Status: Triaged => In Progress ** Changed in: ubuntu-release-upgrader (Ubuntu) Assignee: (unassigned) => Barry Warsaw (barry) -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1102593 Title: do-release-upgrade crashed with UnboundLocalError in doDistUpgradeFetching(): local variable 'e' referenced before assignment To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1102593/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
