Closed
Description
Bug description
Linting:
lst = []
for _var in lst:
del _var
pylint crashed with a AstroidError
and with the following stacktrace:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 769, in _lint_file
check_astroid_module(module)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1029, in check_astroid_module
retval = self._check_astroid_module(
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1079, in _check_astroid_module
walker.walk(node)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 93, in walk
self.walk(child)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 93, in walk
self.walk(child)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 93, in walk
self.walk(child)
[Previous line repeated 1 more time]
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 90, in walk
callback(astroid)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/checkers/modified_iterating_checker.py", line 60, in visit_for
self._modified_iterating_check_on_node_and_children(body_node, iter_obj)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/checkers/modified_iterating_checker.py", line 66, in _modified_iterating_check_on_node_and_children
self._modified_iterating_check(body_node, iter_obj)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/checkers/modified_iterating_checker.py", line 96, in _modified_iterating_check
args=(iter_obj.name,),
AttributeError: 'Attribute' object has no attribute 'name'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 734, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 771, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
Expected behavior
No crash.
Pylint version
pylint-2.15.0
astroid-2.12.5
CPython 3.8.13
OS / Environment
ubuntu-latest