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

Pylint crashes when encoureting a call to range with no arguments #3735

Closed
cpitclaudel opened this issue Jul 10, 2020 · 2 comments · Fixed by #3999
Closed

Pylint crashes when encoureting a call to range with no arguments #3735

cpitclaudel opened this issue Jul 10, 2020 · 2 comments · Fixed by #3999
Assignees
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash

Comments

@cpitclaudel
Copy link
Contributor

Steps to reproduce

echo 'for x in range(): pass' | pylint test --from-stdin

Current behavior

************* Module alectryon.test
test:1:0: C0114: Missing module docstring (missing-module-docstring)
Traceback (most recent call last):
  File "/home/clement/.local/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/__init__.py", line 22, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/lint/run.py", line 344, in __init__
    linter.check(args)
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 864, in check
    self._check_files(
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 904, in _check_files
    self._check_file(get_ast, check_astroid_module, name, filepath, modname)
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 930, in _check_file
    check_astroid_module(ast_node)
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1062, in check_astroid_module
    retval = self._check_astroid_module(
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1107, in _check_astroid_module
    walker.walk(ast_node)
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 75, in walk
    self.walk(child)
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 72, in walk
    callback(astroid)
  File "/home/clement/.local/lib/python3.8/site-packages/pylint/checkers/refactoring.py", line 1346, in visit_for
    if not isinstance(node.iter.args[-1], astroid.Call):
IndexError: list index out of range

Expected behavior

No crash

pylint --version output

pylint 2.5.3
astroid 2.4.2
Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0]
@AWhetter AWhetter added Bug 🪲 Crash 💥 A bug that makes pylint crash labels Sep 8, 2020
@JerryBaboona
Copy link

JerryBaboona commented Dec 16, 2020

Experienced the same behaviour with

pylint 2.6.0
astroid 2.4.2
Python 3.7.7 (default, Dec  4 2020, 15:47:44) 

In our case the code that raised was passing invalid kwargs into range, rather than nothing at all as in @cpitclaudel example.

To reproduce:
echo 'for x in range(a=10): pass' | pylint test --from-stdin

@PCManticore
Copy link
Contributor

Thanks for the report.

PCManticore added a commit that referenced this issue Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Crash 💥 A bug that makes pylint crash
Projects
None yet
4 participants