Detect misuse of except
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| Pyflakes |
New
|
Wishlist
|
Unassigned | |
| pyflakes (Debian) |
Confirmed
|
Unknown
|
Bug Description
It would be nice if pyflakes could detect mistakes like this:
try:
oldtime = os.path.
except OSError, IOError:
oldtime = 0
In the general case, it's obviously difficult to tell whether this is an error or not; but I suspect that handling the exception variable name as a binding would give you a "redefinition of Foo" warning in most of the cases where a mistake has been made.
Changed in pyflakes: | |
importance: | Undecided → Wishlist |
Jean-Paul Calderone (exarkun) wrote : | #1 |
Changed in pyflakes (Debian): | |
status: | Unknown → New |
Changed in pyflakes (Debian): | |
status: | New → Confirmed |
Pyflakes 0.5.0 does generate the warning "local variable 'IOError' is assigned to but never used", so I believe this has been fixed.
Tristan Seligmann (mithrandi) wrote : | #3 |
You only get the unused-
Marcin Cieślak (saperski) wrote : | #4 |
There is no warning as of pyflakes 0.7.3, marking as fixed
Changed in pyflakes: | |
status: | New → Fix Released |
Marcin Cieślak (saperski) wrote : | #5 |
er, sorry, misunderstood... should be reopened again
Changed in pyflakes: | |
status: | Fix Released → New |
Sounds reasonable. At least it would be interesting to run such a check against existing codebases to see what comes up. :)