Skip to content

Commit

Permalink
Catch ValueError - generator already executing (#9454)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Feb 22, 2024
1 parent a83e6b9 commit d4f0ef7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
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__

0 comments on commit d4f0ef7

Please sign in to comment.