https://github.com/python/cpython/commit/6b96dc3bc459d2a5f912c32c076319a850900af0
commit: 6b96dc3bc459d2a5f912c32c076319a850900af0
branch: 3.14
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-10-10T12:49:26Z
summary:
[3.14] Detect @reap_threads misuse (on a class) (#158937) (#159116)
Detect @reap_threads misuse (on a class) (#158937)
(cherry picked from commit 565f76fee1fe1f3ea39aee203e2ed4887a67bc11)
files:
M Lib/test/support/threading_helper.py
diff --git a/Lib/test/support/threading_helper.py
b/Lib/test/support/threading_helper.py
index cf87233f0e2e938..31be31ac9a9dad8 100644
--- a/Lib/test/support/threading_helper.py
+++ b/Lib/test/support/threading_helper.py
@@ -1,6 +1,7 @@
import _thread
import contextlib
import functools
+import inspect
import sys
import threading
import time
@@ -59,6 +60,11 @@ def reap_threads(func):
"""Use this function when threads are being used. This will
ensure that the threads are cleaned up even when the test fails.
"""
+
+ if inspect.isclass(func):
+ # It should be used on each test method, not on the whole class
+ raise ValueError("@reap_threads is not compatible with classes")
+
@functools.wraps(func)
def decorator(*args):
key = threading_setup()
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]