False positive undefined name after del in branch
Bug #1308508 reported by
Dima Tisnek
This bug affects 3 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
New
|
Wishlist
|
Unassigned |
Bug Description
Consider this test code:
def foo():
bar = 1
if 0:
del bar
else:
del bar
pyflakes reports test.py:6: undefined name 'bar', that is 2nd `del bar` is considered in error.
understandably it is impossible to analyse all code paths in general case, so how about tagging `bar` as `uncertain if label is present` and allowing to `del` it?
To post a comment you must log in.
Here is another false positive, for a not-so-subtle case:
Using flake8, which uses PyFlakes, I get the report:
board.py:14:19: F821 undefined name 'StandardError'
However, StandardError is a built-in exception in Python 2 (but not in Python 3).