-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Milestone
Description
Bug description
# pylint: disable=missing-module-docstring, missing-function-docstring
def f():
try:
raise ValueError('inner')
except ValueError as e:
print(e)
try:
raise ValueError('outer')
except ValueError as e:
print(e)
# print(e) # NameError: name 'e' is not defined
Configuration
No response
Command used
pylint a.py
Pylint output
************* Module a
a.py:5:4: W0621: Redefining name 'e' from outer scope (line 10) (redefined-outer-name)
Expected behavior
Pylint must not complain about reusing variables bound to the exception in except clauses because they are in fact not defined outside the corresponding except clause (as can be seen by uncommenting the last line in the example).
Pylint version
pylint 3.2.2
astroid 3.2.2
Python 3.12.3 (main, Apr 10 2024, 05:33:47) [GCC 13.2.0]
OS / Environment
No response
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation