-
Notifications
You must be signed in to change notification settings - Fork 180
Unused variable in except clauses differs between py2 and py3 #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This expected. Python 3 clears the variable while Python 2 does not. |
@myint: I understand it's safer than previous versions, but isn't it useful to catch unused code? |
@myint Apart from being inconsistent; and apart from it actually being unused, it's still IMO a good bug-catching check, because:
does cause an UnboundLocalError in Py3. |
Does #293 fix it for you? |
Yes, the original bug we found is now caught by your fix, thanks! |
@jdufresne actually fixed this in #293 a month prior. 😄 |
Thanks for testing. I updated the PR to reference this issue. |
The following code gives a warning in py2 but not py3.
But only if the try clause is inside a function, otherwise it passes on both.
test.py:5:25: F841 local variable 'e' is assigned to but never used
Is this a bug or a new feature? Could not find anything related to this "regression" but currently py3 does not catch issues py2 would have caught. This is a problem when writing compatible code at the very least.
Could be related to this PR: #59 (found here https://github.com/PyCQA/pyflakes/blob/master/pyflakes/checker.py#L1325)
The text was updated successfully, but these errors were encountered: