Skip to content

Crash with python 3.12 alpha #8588

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

Closed
hannob opened this issue Apr 18, 2023 · 2 comments
Closed

Crash with python 3.12 alpha #8588

hannob opened this issue Apr 18, 2023 · 2 comments
Labels
Crash 💥 A bug that makes pylint crash Duplicate 🐫 Duplicate of an already existing issue python 3.12

Comments

@hannob
Copy link

hannob commented Apr 18, 2023

Bug description

When parsing the following file:

def test():
 return
setattr(test, '_xx', True)
print(locals().items())

pylint crashed with a AstroidError and with the following stacktrace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
StopIteration

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 811, in _lint_file
    check_astroid_module(module)
  File "/usr/local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1085, in check_astroid_module
    retval = self._check_astroid_module(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1135, in _check_astroid_module
    walker.walk(node)
  File "/usr/local/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/usr/local/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/usr/local/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File "/usr/local/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "/usr/local/lib/python3.12/site-packages/pylint/checkers/base/basic_checker.py", line 713, in visit_call
    if utils.is_terminating_func(node):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pylint/checkers/utils.py", line 2202, in is_terminating_func
    return True
           ^^^^
  File "/usr/local/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
    yield from self._infer(context=context, **kwargs)
  File "/usr/local/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/astroid/decorators.py", line 120, in wrapped
    yielded.add(ares)
  File "/usr/local/lib/python3.12/site-packages/astroid/inference.py", line 358, in infer_attribute
    for owner in self.expr.infer(context):
  File "/usr/local/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 "/usr/local/lib/python3.12/site-packages/astroid/decorators.py", line 149, in raise_if_nothing_inferred
    raise InferenceError(
astroid.exceptions.InferenceError: StopIteration raised without any error information.

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 775, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File "/usr/local/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 813, in _lint_file
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError


### Configuration

```ini
This happens with pylint running in a python 3.12 (aka alpha) environment, e.g. when using github actions with python 3.12-dev.

It can be reproduced within docker:

docker run --rm -ti python:3.12.0a7 /bin/bash
echo -en "def test():\n return\nsetattr(test, '_xx', True)\nprint(locals().items())\n" > test.py
pip install pylint
pylint test.py


### Command used

```shell
pylint test.py

Pylint output

/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 '/root/.cache/pylint/pylint-crash-2023-04-18-07-13-47.txt'. (astroid-error)

Expected behavior

no crash

Pylint version

pylint 2.17.2
astroid 2.15.3
Python 3.12.0a7 (main, Apr 12 2023, 14:13:09) [GCC 10.2.1 20210110]

OS / Environment

Debian image with python 3.12

Additional dependencies

No response

@hannob hannob added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 18, 2023
@Pierre-Sassoulas Pierre-Sassoulas added Crash 💥 A bug that makes pylint crash Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning python 3.12 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 18, 2023
@hartwork
Copy link

I believe even this subset is enough to reproduce, I see the same traceback with Python 3.12a7 (but not 3.11.3):

print(locals().items())

@jacobtylerwalls
Copy link
Member

Thanks for the report. This is an upstream issue in CPython, fixed in their main branch (see #8695 (comment)). Closing as duplicate of #8695.

@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2023
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue and removed Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning labels May 18, 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 python 3.12
Projects
None yet
Development

No branches or pull requests

4 participants