Skip to content

Python 3.12 - ValueError: generator already executing #9138

@sivel

Description

@sivel

Bug description

It seems that with a combination of a commit to astroid, and a change in Python 3.12, I am getting a ValueError: generator already executing.

Unfortunately, despite about 12 hours of trying, I don't have a simple reproducer, and this will involve running pylint against https://github.com/ansible/ansible

I've logged here instead of directly against astroid, as I was not able to find an easy way to cause the error with astroid alone.

Configuration

N/A

Command used

git clone [email protected]:ansible/ansible.git
cd ansible
python3.12 -m pylint lib/ansible/playbook/base.py > /dev/null

Pylint output

Traceback (most recent call last):
  File ".../astroid/astroid/decorators.py", line 104, in inner
    yield from generator
ValueError: generator already executing

If I insert additional debugging into astroid, to use traceback.print_stack() when that ValueError happens, I see something like:

Traceback...

  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File ".../lib/python3.12/site-packages/pylint/__main__.py", line 10, in <module>
    pylint.run_pylint()
  File ".../lib/python3.12/site-packages/pylint/__init__.py", line 34, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File ".../lib/python3.12/site-packages/pylint/lint/run.py", line 211, in __init__
    linter.check(args)
  File ".../lib/python3.12/site-packages/pylint/lint/pylinter.py", line 704, in check
    self._lint_files(ast_per_fileitem, check_astroid_module)
  File ".../lib/python3.12/site-packages/pylint/lint/pylinter.py", line 752, in _lint_files
    self._lint_file(fileitem, module, check_astroid_module)
  File ".../lib/python3.12/site-packages/pylint/lint/pylinter.py", line 788, in _lint_file
    check_astroid_module(module)
  File ".../lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1017, in check_astroid_module
    retval = self._check_astroid_module(
  File ".../lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1069, in _check_astroid_module
    walker.walk(node)
  File ".../lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File ".../lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File ".../lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
    self.walk(child)
  File ".../lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File ".../lib/python3.12/site-packages/pylint/checkers/typecheck.py", line 1440, in visit_call
    called, implicit_args, callable_name = _determine_callable(called)
  File ".../lib/python3.12/site-packages/pylint/checkers/typecheck.py", line 636, in _determine_callable
    new = callable_obj.local_attr("__new__")[-1]
  File ".../astroid/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2327, in local_attr
    class_node = next(self.local_attr_ancestors(name, context), None)
  File ".../astroid/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2279, in local_attr_ancestors
    ancestors: Iterable[ClassDef] = self.mro(context)[1:]
  File ".../astroid/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2924, in mro
    return self._compute_mro(context=context)
  File ".../astroid/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2893, in _compute_mro
    inferred_bases = list(self._inferred_bases(context=context))
  File ".../astroid/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2873, in _inferred_bases
    baseobj = next(
  File ".../astroid/astroid/decorators.py", line 56, in wrapped
    yield res
  File ".../astroid/astroid/bases.py", line 181, in _infer_stmts
    yield inf
  File ".../astroid/astroid/nodes/node_ng.py", line 175, in infer
    yield result
  File ".../astroid/astroid/decorators.py", line 56, in wrapped
    yield res
  File ".../astroid/astroid/bases.py", line 181, in _infer_stmts
    yield inf
  File ".../astroid/astroid/nodes/node_ng.py", line 175, in infer
    yield result
  File ".../astroid/astroid/decorators.py", line 56, in wrapped
    yield res
  File ".../astroid/astroid/bases.py", line 181, in _infer_stmts
    yield inf
  File ".../astroid/astroid/nodes/node_ng.py", line 175, in infer
    yield result
  File ".../astroid/astroid/decorators.py", line 56, in wrapped
    yield res
  File ".../astroid/astroid/nodes/node_ng.py", line 175, in infer
    yield result
  File ".../astroid/astroid/decorators.py", line 107, in inner
    traceback.print_stack(file=sys.stderr)

Expected behavior

No traceback

Pylint version

astroid 3.0.0
pylint 3.0.1
Python 3.12.0

OS / Environment

N/A

Additional dependencies

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    AstroidRelated to astroidCrash 💥A bug that makes pylint crashNeeds investigation 🔬A bug or crash where it's not immediately obvious what is happenningUpstream Bug 🪲Bug in a dependency of pylint that is not astroidpython 3.12

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions