del of exception causes Exception

Bug #1578903 reported by John Vandenberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Critical
Phil Frost

Bug Description

The following code causes an exception

try:
    pass
except Exception as e:
    del e

$ python3.4 -m pyflakes test_del_exception.py
Traceback (most recent call last):
  File "/usr/lib64/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/__main__.py", line 5, in <module>
    main(prog='pyflakes')
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py", line 184, in main
    warnings = checkRecursive(args, reporter)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py", line 141, in checkRecursive
    warnings += checkPath(sourcePath, reporter)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py", line 108, in checkPath
    return check(codestr, filename, reporter)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/api.py", line 69, in check
    w = checker.Checker(tree, filename)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py", line 425, in __init__
    self.handleChildren(tree)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py", line 747, in handleChildren
    self.handleNode(node, tree)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py", line 794, in handleNode
    handler(node)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py", line 1196, in TRY
    self.handleChildren(node, omit='body')
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py", line 747, in handleChildren
    self.handleNode(node, tree)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py", line 794, in handleNode
    handler(node)
  File "/usr/lib/python3.4/site-packages/pyflakes-1.2.1-py3.4.egg/pyflakes/checker.py", line 1226, in EXCEPTHANDLER
    del self.scope[node.name]
KeyError: 'e'

This was introduced in 1.2.0 with https://github.com/pyflakes/pyflakes/commit/2a698f87c02a43d4489e30481e9def14ed4b4431

Phil Frost (bitglue)
Changed in pyflakes:
importance: Undecided → Critical
status: New → Confirmed
Revision history for this message
Phil Frost (bitglue) wrote :

Looks like this happens with Python 3 only.

Revision history for this message
Phil Frost (bitglue) wrote :
Changed in pyflakes:
status: Confirmed → In Progress
assignee: nobody → Phil Frost (bitglue)
Revision history for this message
John Vandenberg (jayvdb) wrote :

Yes, the new exception processing which causes this is Python 3 only

Phil Frost (bitglue)
Changed in pyflakes:
status: In Progress → Fix Committed
Phil Frost (bitglue)
Changed in pyflakes:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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