do-release-upgrade crashed with UnboundLocalError in doDistUpgradeFetching(): local variable 'e' referenced before assignment

Bug #1102593 reported by alfredo
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
ubuntu-release-upgrader (Ubuntu)
Fix Released
Medium
Barry Warsaw

Bug Description

.

ProblemType: Crash
DistroRelease: Ubuntu 13.04
Package: ubuntu-release-upgrader-core 1:0.192.4
ProcVersionSignature: Ubuntu 3.8.0-1.5-generic 3.8.0-rc4
Uname: Linux 3.8.0-1-generic i686
ApportVersion: 2.8-0ubuntu2
Architecture: i386
CrashDB: ubuntu
Date: Sun Jan 20 10:22:16 2013
ExecutablePath: /usr/bin/do-release-upgrade
InstallationDate: Installed on 2012-12-18 (34 days ago)
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release i386 (20120423)
InterpreterPath: /usr/bin/python3.3
MarkForUpload: True
PackageArchitecture: all
ProcCmdline: /usr/bin/python3 /usr/lib/ubuntu-release-upgrader/do-partial-upgrade --frontend=DistUpgradeViewGtk3
ProcEnviron:
 SHELL=/bin/bash
 LANG=es_MX.UTF-8
 LANGUAGE=es_MX:es
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
PythonArgs: ['/usr/bin/do-release-upgrade', '--frontend=DistUpgradeViewGtk3']
SourcePackage: ubuntu-release-upgrader
Title: do-release-upgrade crashed with UnboundLocalError in doDistUpgradeFetching(): local variable 'e' referenced before assignment
UpgradeStatus: Upgraded to raring on 2013-01-16 (4 days ago)
UserGroups:

Revision history for this message
alfredo (alftom) wrote :
tags: removed: need-duplicate-check
Changed in ubuntu-release-upgrader (Ubuntu):
importance: Undecided → Medium
information type: Private → Public
Changed in ubuntu-release-upgrader (Ubuntu):
status: New → Triaged
Revision history for this message
Brian Murray (brian-murray) wrote :

e is set to None in line 1031 so I'm not certain how this happens.

Revision history for this message
Barry Warsaw (barry) wrote :

I don't think it can -- with the current Raring or Quantal branch. Setting e = None on that line should do the trick, and that was added by cjwatson in revno 2.1.7 for 1:0.181. If they've got:

Package: ubuntu-release-upgrader-core 1:0.192.4

I can't see how they'd be hitting this. OTOH, note that the reference to 'e' on the current trunk branch is actually at line 1062, so it certainly seems like they are using an out of date version.

Revision history for this message
Brian Murray (brian-murray) wrote :

Downloading the source from https://launchpad.net/ubuntu/+source/ubuntu-release-upgrader/1:0.192.4 the line number for this error message is 1060 and as e is set to None before it is used.

Revision history for this message
Barry Warsaw (barry) wrote :

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.

Changed in ubuntu-release-upgrader (Ubuntu):
status: Triaged → In Progress
assignee: nobody → Barry Warsaw (barry)
Barry Warsaw (barry)
Changed in ubuntu-release-upgrader (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-release-upgrader - 1:0.192.9

---------------
ubuntu-release-upgrader (1:0.192.9) raring; urgency=low

  [ Barry Warsaw ]
  * Fix UnboundLocalError caused by corner case in the Python 3 language
    spec. (LP: #1102593)

  [ Jonathan Riddell ]
  * Use correct argument for frontend in kubuntu-devel-release-upgrade

  [ Brian Murray ]
  * Remove cups-pdf from ForcedObsoletes in DistUpgrade.cfg (LP: #457221)
 -- Brian Murray <email address hidden> Thu, 18 Apr 2013 13:10:08 -0700

Changed in ubuntu-release-upgrader (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.