]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-88750: Remove the PYTHONTHREADDEBUG env var support. (#92509)
authorGregory P. Smith <greg@krypto.org>
Mon, 9 May 2022 23:03:46 +0000 (16:03 -0700)
committerGitHub <noreply@github.com>
Mon, 9 May 2022 23:03:46 +0000 (16:03 -0700)
Remove the `PYTHONTHREADDEBUG` env var support.
Remove no-op dprintf() macro calls.

Doc/using/cmdline.rst
Doc/using/configure.rst
Lib/test/test_threading.py
Misc/NEWS.d/next/Core and Builtins/2022-05-08-19-43-31.gh-issue-88750.1BjJg-.rst [new file with mode: 0644]
Misc/python.man
Python/pylifecycle.c
Python/thread.c
Python/thread_nt.h
Python/thread_pthread.h

index 668459f352008265e97c3eb0c86b3e2741054798..bc54ed8691825fe2f560b7df27a310d37c5164fb 100644 (file)
@@ -999,15 +999,6 @@ conflict.
 Debug-mode variables
 ~~~~~~~~~~~~~~~~~~~~
 
-.. envvar:: PYTHONTHREADDEBUG
-
-   If set, Python will print threading debug info into stdout.
-
-   Need a :ref:`debug build of Python <debug-build>`.
-
-   .. deprecated-removed:: 3.10 3.12
-
-
 .. envvar:: PYTHONDUMPREFS
 
    If set, Python will dump objects and reference counts still alive after
index 4bf9b84e6b90fda5478ce51b3d66b0bac954dd91..d61647f5ea71eacb682b1ff88dfaadef05554b03 100644 (file)
@@ -278,7 +278,6 @@ Effects of a debug build:
 * Add ``d`` to :data:`sys.abiflags`.
 * Add :func:`sys.gettotalrefcount` function.
 * Add :option:`-X showrefcount <-X>` command line option.
-* Add :envvar:`PYTHONTHREADDEBUG` environment variable.
 * Add support for the ``__lltrace__`` variable: enable low-level tracing in the
   bytecode evaluation loop if the variable is defined.
 * Install :ref:`debug hooks on memory allocators <default-memory-allocators>`
index f7dea136a87c0d23836072f1c27d7aea41c7d7f8..a1bf354e65e2e1597f826f93c5c8902dbd217b62 100644 (file)
@@ -945,16 +945,6 @@ class ThreadTests(BaseTestCase):
             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)
-
     def test_import_from_another_thread(self):
         # bpo-1596321: If the threading module is first import from a thread
         # different than the main thread, threading._shutdown() must handle
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-05-08-19-43-31.gh-issue-88750.1BjJg-.rst b/Misc/NEWS.d/next/Core and Builtins/2022-05-08-19-43-31.gh-issue-88750.1BjJg-.rst
new file mode 100644 (file)
index 0000000..bc8d413
--- /dev/null
@@ -0,0 +1,2 @@
+The deprecated debug build only ``PYTHONTHREADDEBUG`` environment variable
+no longer does anything.
index c2e7e507e2fd690b787c0bcb8d6ae22c1bb6016b..69dab58a9aac263b9c6091e175430baa6393ab6e 100644 (file)
@@ -560,9 +560,6 @@ can be set to the callable of your debugger of choice.
 Setting these variables only has an effect in a debug build of Python, that is,
 if Python was configured with the
 \fB\--with-pydebug\fP build option.
-.IP PYTHONTHREADDEBUG
-If this environment variable is set, Python will print threading debug info.
-The feature is deprecated in Python 3.10 and will be removed in Python 3.12.
 .IP PYTHONDUMPREFS
 If this environment variable is set, Python will dump objects and reference
 counts still alive after shutting down the interpreter.
index 273f6d62b2a204b9b6d42fd626de5902fd50ad7a..8644b5b68b6c571836774456874e200e25627556 100644 (file)
@@ -1091,8 +1091,6 @@ pyinit_main_reconfigure(PyThreadState *tstate)
 static PyStatus
 init_interp_main(PyThreadState *tstate)
 {
-    extern void _PyThread_debug_deprecation(void);
-
     assert(!_PyErr_Occurred(tstate));
 
     PyStatus status;
@@ -1194,9 +1192,6 @@ init_interp_main(PyThreadState *tstate)
 #endif
     }
 
-    // Warn about PYTHONTHREADDEBUG deprecation
-    _PyThread_debug_deprecation();
-
     assert(!_PyErr_Occurred(tstate));
 
     return _PyStatus_OK();
index e80e8a906bc8e094c2a28f28412bd6a4ade62508..846f02545271cf7e3e12bfa36a58af7d469ca214 100644 (file)
 
 #endif /* _POSIX_THREADS */
 
-
-#ifdef Py_DEBUG
-static int thread_debug = 0;
-#  define dprintf(args)   (void)((thread_debug & 1) && printf args)
-#else
-#  define dprintf(args)
-#endif
-
 static int initialized;
 
 static void PyThread__init_thread(void); /* Forward */
@@ -57,42 +49,12 @@ static void PyThread__init_thread(void); /* Forward */
 void
 PyThread_init_thread(void)
 {
-#ifdef Py_DEBUG
-    const char *p = Py_GETENV("PYTHONTHREADDEBUG");
-
-    if (p) {
-        if (*p)
-            thread_debug = atoi(p);
-        else
-            thread_debug = 1;
-    }
-#endif /* Py_DEBUG */
     if (initialized)
         return;
     initialized = 1;
-    dprintf(("PyThread_init_thread called\n"));
     PyThread__init_thread();
 }
 
-void
-_PyThread_debug_deprecation(void)
-{
-#ifdef Py_DEBUG
-    if (thread_debug) {
-        // Flush previous dprintf() logs
-        fflush(stdout);
-        if (PyErr_WarnEx(PyExc_DeprecationWarning,
-                         "The threading debug (PYTHONTHREADDEBUG environment "
-                         "variable) is deprecated and will be removed "
-                         "in Python 3.12",
-                         0))
-        {
-            _PyErr_WriteUnraisableMsg("at Python startup", NULL);
-        }
-    }
-#endif
-}
-
 #if defined(_POSIX_THREADS)
 #   define PYTHREAD_NAME "pthread"
 #   include "thread_pthread.h"
index 084bd5873148769d0a0fa2f7839d0a578782781e..b1defad426591f39a97b0c2dd80c8a2c2e9d2181 100644 (file)
@@ -188,8 +188,6 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
     unsigned threadID;
     callobj *obj;
 
-    dprintf(("%lu: PyThread_start_new_thread called\n",
-             PyThread_get_thread_ident()));
     if (!initialized)
         PyThread_init_thread();
 
@@ -209,14 +207,10 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
          * too many threads".
          */
         int e = errno;
-        dprintf(("%lu: PyThread_start_new_thread failed, errno %d\n",
-                 PyThread_get_thread_ident(), e));
         threadID = (unsigned)-1;
         HeapFree(GetProcessHeap(), 0, obj);
     }
     else {
-        dprintf(("%lu: PyThread_start_new_thread succeeded: %p\n",
-                 PyThread_get_thread_ident(), (void*)hThread));
         CloseHandle(hThread);
     }
     return threadID;
@@ -257,7 +251,6 @@ PyThread_get_thread_native_id(void)
 void _Py_NO_RETURN
 PyThread_exit_thread(void)
 {
-    dprintf(("%lu: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
     if (!initialized)
         exit(0);
     _endthreadex(0);
@@ -273,22 +266,17 @@ PyThread_allocate_lock(void)
 {
     PNRMUTEX aLock;
 
-    dprintf(("PyThread_allocate_lock called\n"));
     if (!initialized)
         PyThread_init_thread();
 
     aLock = AllocNonRecursiveMutex() ;
 
-    dprintf(("%lu: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock));
-
     return (PyThread_type_lock) aLock;
 }
 
 void
 PyThread_free_lock(PyThread_type_lock aLock)
 {
-    dprintf(("%lu: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
-
     FreeNonRecursiveMutex(aLock) ;
 }
 
@@ -333,9 +321,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock,
         milliseconds = INFINITE;
     }
 
-    dprintf(("%lu: PyThread_acquire_lock_timed(%p, %lld) called\n",
-             PyThread_get_thread_ident(), aLock, microseconds));
-
     if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock,
                                         (DWORD)milliseconds) == WAIT_OBJECT_0) {
         success = PY_LOCK_ACQUIRED;
@@ -344,9 +329,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock,
         success = PY_LOCK_FAILURE;
     }
 
-    dprintf(("%lu: PyThread_acquire_lock(%p, %lld) -> %d\n",
-             PyThread_get_thread_ident(), aLock, microseconds, success));
-
     return success;
 }
 int
@@ -358,10 +340,9 @@ PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
 void
 PyThread_release_lock(PyThread_type_lock aLock)
 {
-    dprintf(("%lu: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
-
-    if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
-        dprintf(("%lu: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError()));
+    if (aLock) {
+        (void)LeaveNonRecursiveMutex((PNRMUTEX) aLock);
+    }
 }
 
 /* minimum/maximum thread stack sizes supported */
index c90ab25d4841d814ddb94f27adc9d6137136d053..2237018e9cbc2cd6173524f967e2f9d73fb96aad 100644 (file)
@@ -252,7 +252,6 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
     size_t      tss;
 #endif
 
-    dprintf(("PyThread_start_new_thread called\n"));
     if (!initialized)
         PyThread_init_thread();
 
@@ -358,7 +357,6 @@ PyThread_get_thread_native_id(void)
 void _Py_NO_RETURN
 PyThread_exit_thread(void)
 {
-    dprintf(("PyThread_exit_thread called\n"));
     if (!initialized)
         exit(0);
     pthread_exit(0);
@@ -376,7 +374,6 @@ PyThread_allocate_lock(void)
     sem_t *lock;
     int status, error = 0;
 
-    dprintf(("PyThread_allocate_lock called\n"));
     if (!initialized)
         PyThread_init_thread();
 
@@ -392,7 +389,6 @@ PyThread_allocate_lock(void)
         }
     }
 
-    dprintf(("PyThread_allocate_lock() -> %p\n", (void *)lock));
     return (PyThread_type_lock)lock;
 }
 
@@ -403,7 +399,6 @@ PyThread_free_lock(PyThread_type_lock lock)
     int status, error = 0;
 
     (void) error; /* silence unused-but-set-variable warning */
-    dprintf(("PyThread_free_lock(%p) called\n", lock));
 
     if (!thelock)
         return;
@@ -435,8 +430,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
     int status, error = 0;
 
     (void) error; /* silence unused-but-set-variable warning */
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n",
-             lock, microseconds, intr_flag));
 
     _PyTime_t timeout;  // relative timeout
     if (microseconds >= 0) {
@@ -544,8 +537,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
         success = PY_LOCK_FAILURE;
     }
 
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
-             lock, microseconds, intr_flag, success));
     return success;
 }
 
@@ -556,7 +547,6 @@ PyThread_release_lock(PyThread_type_lock lock)
     int status, error = 0;
 
     (void) error; /* silence unused-but-set-variable warning */
-    dprintf(("PyThread_release_lock(%p) called\n", lock));
 
     status = sem_post(thelock);
     CHECK_STATUS("sem_post");
@@ -573,7 +563,6 @@ PyThread_allocate_lock(void)
     pthread_lock *lock;
     int status, error = 0;
 
-    dprintf(("PyThread_allocate_lock called\n"));
     if (!initialized)
         PyThread_init_thread();
 
@@ -599,7 +588,6 @@ PyThread_allocate_lock(void)
         }
     }
 
-    dprintf(("PyThread_allocate_lock() -> %p\n", (void *)lock));
     return (PyThread_type_lock) lock;
 }
 
@@ -610,7 +598,6 @@ PyThread_free_lock(PyThread_type_lock lock)
     int status, error = 0;
 
     (void) error; /* silence unused-but-set-variable warning */
-    dprintf(("PyThread_free_lock(%p) called\n", lock));
 
     /* some pthread-like implementations tie the mutex to the cond
      * and must have the cond destroyed first.
@@ -632,9 +619,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
     pthread_lock *thelock = (pthread_lock *)lock;
     int status, error = 0;
 
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n",
-             lock, microseconds, intr_flag));
-
     if (microseconds == 0) {
         status = pthread_mutex_trylock( &thelock->mut );
         if (status != EBUSY)
@@ -694,8 +678,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
     }
 
     if (error) success = PY_LOCK_FAILURE;
-    dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
-             lock, microseconds, intr_flag, success));
     return success;
 }
 
@@ -706,7 +688,6 @@ PyThread_release_lock(PyThread_type_lock lock)
     int status, error = 0;
 
     (void) error; /* silence unused-but-set-variable warning */
-    dprintf(("PyThread_release_lock(%p) called\n", lock));
 
     status = pthread_mutex_lock( &thelock->mut );
     CHECK_STATUS_PTHREAD("pthread_mutex_lock[3]");