bpo-44584: Deprecate PYTHONTHREADDEBUG env var (GH-27065)
The threading debug (PYTHONTHREADDEBUG environment variable) is
deprecated in Python 3.10 and will be removed in Python 3.12. This
feature requires a debug build of Python.
(cherry picked from commit 4d77691172aae81bdcbb0ea75839d0e896c43781)
Co-authored-by: Victor Stinner <vstinner@python.org>
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 23fe2d3..c51de6f 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -32,6 +32,9 @@
# on platforms known to behave badly.
platforms_to_skip = ('netbsd5', 'hp-ux11')
+# Is Python built with Py_DEBUG macro defined?
+Py_DEBUG = hasattr(sys, 'gettotalrefcount')
+
def restore_default_excepthook(testcase):
testcase.addCleanup(setattr, threading, 'excepthook', threading.excepthook)
@@ -915,6 +918,16 @@ def noop(): pass
threading.Thread(target=noop).start()
# Thread.join() is not called
+ @unittest.skipUnless(Py_DEBUG, 'need debug build (Py_DEBUG)')
+ def test_debug_deprecation(self):
+ # bpo-44584: The PYTHONTHREADDEBUG environment variable is deprecated
+ rc, out, err = assert_python_ok("-Wdefault", "-c", "pass",
+ PYTHONTHREADDEBUG="1")
+ msg = (b'DeprecationWarning: The threading debug '
+ b'(PYTHONTHREADDEBUG environment variable) '
+ b'is deprecated and will be removed in Python 3.12')
+ self.assertIn(msg, err)
+
class ThreadJoinOnShutdown(BaseTestCase):