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

[Backport maintenance/3.0.x] Catch ValueError - generator already executing #9455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pyenchant_pylint_custom_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ unicode
Uninferable
uninferable
unittest
unraisablehook
untriggered
# prefix for string
ur
Expand Down
4 changes: 4 additions & 0 deletions doc/whatsnew/fragments/9138.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Catch incorrect ValueError ``"generator already executing"`` for Python 3.12.0 - 3.12.2.
This is fixed upstream in Python 3.12.3.

Closes #9138
21 changes: 21 additions & 0 deletions pylint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,25 @@ def modify_sys_path() -> None:
sys.path.pop(1)


def _catch_valueerror(unraisable: sys.UnraisableHookArgs) -> None: # pragma: no cover
"""Overwrite sys.unraisablehook to catch incorrect ValueError.

Python 3.12 introduced changes that sometimes cause astroid to emit ValueErrors
with 'generator already executing'. Fixed in Python 3.12.3 and 3.13.

https://github.com/pylint-dev/pylint/issues/9138
"""
if (
isinstance(unraisable.exc_value, ValueError)
and unraisable.exc_value.args[0] == "generator already executing"
):
return

sys.__unraisablehook__(unraisable)


if (3, 12, 0) <= sys.version_info[:3] < (3, 12, 3):
sys.unraisablehook = _catch_valueerror


version = __version__
Loading