Skip to content
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

Crash on if nested in for in. #7131

Closed
chvp opened this issue Jul 5, 2022 · 0 comments · Fixed by #7132
Closed

Crash on if nested in for in. #7131

chvp opened this issue Jul 5, 2022 · 0 comments · Fixed by #7132
Assignees
Labels
Crash 💥 A bug that makes pylint crash
Milestone

Comments

@chvp
Copy link

chvp commented Jul 5, 2022

Bug description

When parsing the following (excerpt of a) file:

for index, _ in enumerate(lijstv) if len(lijst1) >= len(lijstv) else enumerate(lijst1):
    a = waarde2verschil(lijst1[index] - lijstv[index])

if len(lijst1) < len(lijstv):
    for index2 in range(vers):
        a = waarde2verschil(lijstv[index + index2 + 1])

pylint crashed with a AstroidError and with the following stacktrace:

Traceback (most recent call last):
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 727, in _check_file
    check_astroid_module(ast_node)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 926, in check_astroid_module
    retval = self._check_astroid_module(
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 976, in _check_astroid_module
    walker.walk(node)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 93, in walk
    self.walk(child)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 93, in walk
    self.walk(child)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 93, in walk
    self.walk(child)
  [Previous line repeated 5 more times]
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 90, in walk
    callback(astroid)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 1349, in visit_name
    self._undefined_and_used_before_checker(node, stmt)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 1391, in _undefined_and_used_before_checker
    action, nodes_to_consume = self._check_consumer(
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 1496, in _check_consumer
    self._loopvar_name(node)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 2242, in _loopvar_name
    and assign.iter.args
AttributeError: 'IfExp' object has no attribute 'args'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 684, in _check_files
    self._check_file(get_ast, check_astroid_module, file)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 729, in _check_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError

Configuration

No configuration.

Command used

pylint 9860988.py

Pylint output

************* Module 9860988
9860988.py:7:0: C0305: Trailing newlines (trailing-newlines)
9860988.py:1:0: C0114: Missing module docstring (missing-module-docstring)
9860988.py:1:0: C0103: Module name "9860988" doesn't conform to snake_case naming style (invalid-name)
9860988.py:1:41: E0602: Undefined variable 'lijst1' (undefined-variable)
9860988.py:1:56: E0602: Undefined variable 'lijstv' (undefined-variable)
9860988.py:1:26: E0602: Undefined variable 'lijstv' (undefined-variable)
9860988.py:1:79: E0602: Undefined variable 'lijst1' (undefined-variable)
9860988.py:2:8: E0602: Undefined variable 'waarde2verschil' (undefined-variable)
9860988.py:2:24: E0602: Undefined variable 'lijst1' (undefined-variable)
9860988.py:2:40: E0602: Undefined variable 'lijstv' (undefined-variable)
9860988.py:4:7: E0602: Undefined variable 'lijst1' (undefined-variable)
9860988.py:4:21: E0602: Undefined variable 'lijstv' (undefined-variable)
9860988.py:5:24: E0602: Undefined variable 'vers' (undefined-variable)
9860988.py:6:12: E0602: Undefined variable 'waarde2verschil' (undefined-variable)
9860988.py:6:28: E0602: Undefined variable 'lijstv' (undefined-variable)
Exception on node <Name.index l.6 at 0x7fc6a50d2440> in file '/home/charlotte/repos/dodona/themis/9860988.py'
Traceback (most recent call last):
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 90, in walk
    callback(astroid)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 1349, in visit_name
    self._undefined_and_used_before_checker(node, stmt)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 1391, in _undefined_and_used_before_checker
    action, nodes_to_consume = self._check_consumer(
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 1496, in _check_consumer
    self._loopvar_name(node)
  File "/nix/store/sym07z6bfly57vim5fxmf41xw8knlp25-python3-3.10.5-env/lib/python3.10/site-packages/pylint/checkers/variables.py", line 2242, in _loopvar_name
    and assign.iter.args
AttributeError: 'IfExp' object has no attribute 'args'
9860988.py:1:0: F0002: 9860988.py: Fatal error while checking '9860988.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/home/charlotte/.cache/pylint/pylint-crash-2022-07-05-15.txt'. (astroid-error)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

It should not crash.

Pylint version

pylint 2.14.1
astroid 2.11.5
Python 3.10.5 (main, Jun  6 2022, 12:05:50) [GCC 11.3.0]

OS / Environment

NixOS unstable.

Additional dependencies

No response

@chvp chvp added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jul 5, 2022
@jacobtylerwalls jacobtylerwalls self-assigned this Jul 5, 2022
@jacobtylerwalls jacobtylerwalls added Crash 💥 A bug that makes pylint crash and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 5, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.14.5 milestone Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants