Skip to content

Commit 327785d

Browse files
Catch ValueError - generator already executing (#9454) (#9455)
(cherry picked from commit d4f0ef7) Co-authored-by: Marc Mueller <[email protected]>
1 parent 4d162c3 commit 327785d

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.pyenchant_pylint_custom_dict.txt

+1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ unicode
361361
Uninferable
362362
uninferable
363363
unittest
364+
unraisablehook
364365
untriggered
365366
# prefix for string
366367
ur

doc/whatsnew/fragments/9138.bugfix

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Catch incorrect ValueError ``"generator already executing"`` for Python 3.12.0 - 3.12.2.
2+
This is fixed upstream in Python 3.12.3.
3+
4+
Closes #9138

pylint/__init__.py

+21
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,25 @@ def modify_sys_path() -> None:
9595
sys.path.pop(1)
9696

9797

98+
def _catch_valueerror(unraisable: sys.UnraisableHookArgs) -> None: # pragma: no cover
99+
"""Overwrite sys.unraisablehook to catch incorrect ValueError.
100+
101+
Python 3.12 introduced changes that sometimes cause astroid to emit ValueErrors
102+
with 'generator already executing'. Fixed in Python 3.12.3 and 3.13.
103+
104+
https://github.com/pylint-dev/pylint/issues/9138
105+
"""
106+
if (
107+
isinstance(unraisable.exc_value, ValueError)
108+
and unraisable.exc_value.args[0] == "generator already executing"
109+
):
110+
return
111+
112+
sys.__unraisablehook__(unraisable)
113+
114+
115+
if (3, 12, 0) <= sys.version_info[:3] < (3, 12, 3):
116+
sys.unraisablehook = _catch_valueerror
117+
118+
98119
version = __version__

0 commit comments

Comments
 (0)