[Bug 1102593] Re: do-release-upgrade crashed with UnboundLocalError in doDistUpgradeFetching(): local variable 'e' referenced before assignment

Barry Warsaw 1102593 at bugs.launchpad.net
Thu Apr 18 17:26:49 UTC 2013


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
Foundations Bugs, which is subscribed to ubuntu-release-upgrader in
Ubuntu.
https://bugs.launchpad.net/bugs/1102593

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

Status in “ubuntu-release-upgrader” package in Ubuntu:
  In Progress

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:

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1102593/+subscriptions




More information about the foundations-bugs mailing list