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 enumerate with binary operator in start parameter #7963

Closed
targodan opened this issue Dec 20, 2022 · 4 comments
Closed

Crash on enumerate with binary operator in start parameter #7963

targodan opened this issue Dec 20, 2022 · 4 comments
Labels
Crash 💥 A bug that makes pylint crash Duplicate 🐫 Duplicate of an already existing issue
Milestone

Comments

@targodan
Copy link

targodan commented Dec 20, 2022

Bug description

Minimal example (in our code which initially triggered the bug, the addition consisted of one variable and one literal):

def this_crashes_pylint(arr):
    for i, v in enumerate(arr, 1+1):
        pass

def this_is_fine(arr):
    for i, v in enumerate(arr, 1):
        pass

Configuration

# Default pylint config i.e. no config.

Command used

pylint crash.py

Pylint output

************* Module crash
crash.py:8:0: C0305: Trailing newlines (trailing-newlines)
crash.py:1:0: C0114: Missing module docstring (missing-module-docstring)
crash.py:1:0: C0116: Missing function or method docstring (missing-function-docstring)
Exception on node <For l.2 at 0x7fccd1fa95d0> in file '/tmp/pylintcrash/crash.py'
Traceback (most recent call last):
  File "/tmp/pylintcrash/venv/lib/python3.10/site-packages/pylint/utils/ast_walker.py", line 90, in walk
    callback(astroid)
  File "/tmp/pylintcrash/venv/lib/python3.10/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 682, in visit_for
    self._check_unnecessary_list_index_lookup(node)
  File "/tmp/pylintcrash/venv/lib/python3.10/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 2118, in _check_unnecessary_list_index_lookup
    has_start_arg, confidence = self._enumerate_with_start(node)
  File "/tmp/pylintcrash/venv/lib/python3.10/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 2236, in _enumerate_with_start
    start_val, confidence = self._get_start_value(start_arg)
  File "/tmp/pylintcrash/venv/lib/python3.10/site-packages/pylint/checkers/refactoring/refactoring_checker.py", line 2260, in _get_start_value
    start_val = node.value
AttributeError: 'BinOp' object has no attribute 'value'
crash.py:1:0: F0002: crash.py: Fatal error while checking 'crash.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/corbatto/.cache/pylint/pylint-crash-2022-12-20-08-35-59.txt'. (astroid-error)

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

Expected behavior

Should not crash.

Pylint version

pylint 2.15.9
astroid 2.12.13
Python 3.10.8 (main, Nov  1 2022, 14:18:21) [GCC 12.2.0]

Likely introduced in this release, since we've been checking the exact same lines of code for months if not years without a crash.

OS / Environment

ArchLinux with zen kernel 6.0.12. Terminal: alacritty + tmux + zsh. It also happened on an ubuntu based bamboo worker, don't know the exact version.

Additional dependencies

No response

@targodan targodan added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Dec 20, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Dec 20, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.15.10 milestone Dec 20, 2022
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue !

@clavedeluna
Copy link
Collaborator

This issue has already been fixed and does not happen on the current main branch. @Pierre-Sassoulas surprised the fix hasn't been released? It was fixed here #7824 and should've been backported.

@Pierre-Sassoulas
Copy link
Member

It broke the maintenance branch so we reverted in #7855. We could release 2.16.0, but it's blocked by astroid's 2.13.0 release, which itself is blocked by pylint-dev/astroid#1189 and pylint-dev/astroid#1910. Another way to fix this would be to do a proper cherry-pick on the maintenance branch.

@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.15.10, 2.16.0 Jan 8, 2023
@Pierre-Sassoulas
Copy link
Member

We released astroid 2.13.0, once #8030 is merged and once the blocker issues are resolved we're going to be able to release pylint 2.16.0.

@Pierre-Sassoulas Pierre-Sassoulas closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Duplicate 🐫 Duplicate of an already existing issue and removed Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Jan 8, 2023
karlch added a commit to karlch/vimiv-qt that referenced this issue Jul 6, 2023
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 Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

3 participants