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 is broken with CPython main #101914

Closed
mdboom opened this issue Feb 14, 2023 · 3 comments
Closed

pylint is broken with CPython main #101914

mdboom opened this issue Feb 14, 2023 · 3 comments
Assignees
Labels
3.12 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-bug An unexpected behavior, bug, or error

Comments

@mdboom
Copy link
Contributor

mdboom commented Feb 14, 2023

Bug report

pylint currently crashes with CPython main. I noticed this when I noticed the pylint benchmark in Pyston's benchmark suite was no longer working.

The first bad commit is 4a1c58d (@markshannon), issue #96793, PR #98772.

I don't know whether this is the result of expected breakage (and pylint or astroid needs to modify their code) or there is a specialization failure here.

Your environment

Linux

To reproduce

pip install pylint==2.16.2

Download the example Python file from the pyston macrobenchmark suite

pylint dist.py

Backtrace:

Exception on node <Call l.430 at 0x7ff062d76ae0> in file '/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/data/pylint_target/dist.py'
Traceback (most recent call last):
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/inference.py", line 450, in infer_subscript
    assigned = value.getitem(index_value, context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/nodes/node_classes.py", line 2466, in getitem
    raise AstroidIndexError(index)
astroid.exceptions.AstroidIndexError: <exception str() failed>

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

Traceback (most recent call last):
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/pylint/checkers/base/basic_checker.py", line 705, in visit_call
    if utils.is_terminating_func(node):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/pylint/checkers/utils.py", line 2181, in is_terminating_func
    return True
           ^^^^
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/decorators.py", line 119, in wrapped
    yielded.add(ares)
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/inference.py", line 380, in infer_attribute
    context.boundnode = old_boundnode
    ^^^^^^^^^^^^^^^^^
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
    for i, result in enumerate(self._infer(context=context, **kwargs)):
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/decorators.py", line 119, in wrapped
    yielded.add(ares)
  File "/home/mdboom/Work/builds/python-macrobenchmarks/benchmarks/bm_pylint/venv/lib/python3.12/site-packages/astroid/inference.py", line 458, in infer_subscript
    raise InferenceError(node=self, context=context) from exc
astroid.exceptions.InferenceError: Inference failed for <Subscript l.430 at 0x7ff062d76b40>.
************* Module pylint_target.dist
data/pylint_target/dist.py:1:0: C0302: Too many lines in module (1261/1000) (too-many-lines)
data/pylint_target/dist.py:22:0: E0401: Unable to import 'distutils.errors' (import-error)
data/pylint_target/dist.py:22:0: W4901: Deprecated module 'distutils.errors' (deprecated-module)
data/pylint_target/dist.py:22:0: W0401: Wildcard import distutils.errors (wildcard-import)
data/pylint_target/dist.py:23:0: E0401: Unable to import 'distutils.fancy_getopt' (import-error)
data/pylint_target/dist.py:23:0: W4901: Deprecated module 'distutils.fancy_getopt' (deprecated-module)
data/pylint_target/dist.py:24:0: E0401: Unable to import 'distutils.util' (import-error)
data/pylint_target/dist.py:24:0: W4901: Deprecated module 'distutils.util' (deprecated-module)
data/pylint_target/dist.py:25:0: E0401: Unable to import 'distutils' (import-error)
data/pylint_target/dist.py:25:0: W4901: Deprecated module 'distutils' (deprecated-module)
data/pylint_target/dist.py:26:0: E0401: Unable to import 'distutils.debug' (import-error)
data/pylint_target/dist.py:26:0: W4901: Deprecated module 'distutils.debug' (deprecated-module)
data/pylint_target/dist.py:49:0: R0902: Too many instance attributes (27/7) (too-many-instance-attributes)
data/pylint_target/dist.py:278:26: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
data/pylint_target/dist.py:141:4: R0912: Too many branches (18/12) (too-many-branches)
data/pylint_target/dist.py:141:4: R0915: Too many statements (60/50) (too-many-statements)
data/pylint_target/dist.py:305:8: W0622: Redefining built-in 'dict' (redefined-builtin)
data/pylint_target/dist.py:310:4: C0116: Missing function or method docstring (missing-function-docstring)
data/pylint_target/dist.py:311:8: C0415: Import outside toplevel (pprint.pformat) (import-outside-toplevel)
data/pylint_target/dist.py:328:30: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
data/pylint_target/dist.py:331:30: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
data/pylint_target/dist.py:382:26: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
data/pylint_target/dist.py:386:4: C0116: Missing function or method docstring (missing-function-docstring)
data/pylint_target/dist.py:387:8: C0415: Import outside toplevel (configparser.ConfigParser) (import-outside-toplevel)
data/pylint_target/dist.py:410:30: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
data/pylint_target/dist.py:424:12: C2801: Unnecessarily calls dunder method __init__. Instantiate class directly. (unnecessary-dunder-call)
data/pylint_target/dist.py:1:0: F0002: data/pylint_target/dist.py: Fatal error while checking 'data/pylint_target/dist.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/mdboom/.cache/pylint/pylint-crash-2023-02-14-15-25-33.txt'. (astroid-error)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
@mdboom mdboom added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Feb 14, 2023
@markshannon markshannon self-assigned this Feb 15, 2023
@Eclips4
Copy link
Member

Eclips4 commented Feb 17, 2023

More simple way to reproduce it:

a = b()
func(1)

Backtrace:

************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:1:4: E0602: Undefined variable 'b' (undefined-variable)
Exception on node <Call l.2 at 0x7f4912053dd0> in file '/home/eclips4/projects/test.py'
Traceback (most recent call last):
  File "/home/eclips4/projects/venv_3_12/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "/home/eclips4/projects/venv_3_12/lib/python3.12/site-packages/pylint/checkers/base/basic_checker.py", line 705, in visit_call
    if utils.is_terminating_func(node):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eclips4/projects/venv_3_12/lib/python3.12/site-packages/pylint/checkers/utils.py", line 2181, in is_terminating_func
    return True
           ^^^^
  File "/home/eclips4/projects/venv_3_12/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/home/eclips4/projects/venv_3_12/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/eclips4/projects/venv_3_12/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eclips4/projects/venv_3_12/lib/python3.12/site-packages/astroid/inference.py", line 240, in infer_name
    raise NameInferenceError(
astroid.exceptions.NameInferenceError: 'func' not found in <Module.test l.0 at 0x7f49126cdd30>.
test.py:1:0: F0002: test.py: Fatal error while checking 'test.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/eclips4/.cache/pylint/pylint-crash-2023-02-17-20-32-34.txt'. (astroid-error)

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

@mdboom
Copy link
Contributor Author

mdboom commented Apr 20, 2023

Fixed by #103502.

@mdboom mdboom closed this as completed Apr 20, 2023
@hauntsaninja
Copy link
Contributor

Would be nice if there's a relatively small regression test we could add!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) release-blocker type-bug An unexpected behavior, bug, or error
Projects
Development

No branches or pull requests

5 participants