summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2022-05-09 23:03:46 (GMT)
committerGitHub <noreply@github.com>2022-05-09 23:03:46 (GMT)
commit6ed7c353b8ded48a9128413f35921ddc4e5b1065 (patch)
treeafc47815078dc4b9eb7bc1ca47b97be3ebabcaac /Python
parent22bddc864d3cc04ed218beb3b706ff1790db836a (diff)
downloadcpython-6ed7c353b8ded48a9128413f35921ddc4e5b1065.zip
cpython-6ed7c353b8ded48a9128413f35921ddc4e5b1065.tar.gz
cpython-6ed7c353b8ded48a9128413f35921ddc4e5b1065.tar.bz2
gh-88750: Remove the PYTHONTHREADDEBUG env var support. (#92509)
Remove the `PYTHONTHREADDEBUG` env var support. Remove no-op dprintf() macro calls.
Diffstat (limited to 'Python')
-rw-r--r--Python/pylifecycle.c5
-rw-r--r--Python/thread.c38
-rw-r--r--Python/thread_nt.h25
-rw-r--r--Python/thread_pthread.h19
4 files changed, 3 insertions, 84 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 273f6d6..8644b5b 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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();
diff --git a/Python/thread.c b/Python/thread.c
index e80e8a9..846f025 100644
--- a/Python/thread.c
+++ b/Python/thread.c
@@ -42,14 +42,6 @@
#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"
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 084bd58..b1defad 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -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 */
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index c90ab25..2237018 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -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]");