8000 gh-88750: Remove the PYTHONTHREADDEBUG env var support. (#92509) · python/cpython@6ed7c35 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ed7c35

Browse files
authored
gh-88750: Remove the PYTHONTHREADDEBUG env var support. (#92509)
Remove the `PYTHONTHREADDEBUG` env var support. Remove no-op dprintf() macro calls.
1 parent 22bddc8 commit 6ed7c35

File tree

9 files changed

+5
-107
lines changed

9 files changed

+5
-107
lines changed

Doc/using/cmdline.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,6 @@ conflict.
999999
Debug-mode variables
10001000
~~~~~~~~~~~~~~~~~~~~
10011001

1002-
.. envvar:: PYTHONTHREADDEBUG
1003-
1004-
If set, Python will print threading debug info into stdout.
1005-
1006-
Need a :ref:`debug build of Python <debug-build>`.
< 8000 code>1007-
1008-
.. deprecated-removed:: 3.10 3.12
1009-
1010-
10111002
.. envvar:: PYTHONDUMPREFS
10121003

10131004
If set, Python will dump objects and reference counts still alive after

Doc/using/configure.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ Effects of a debug build:
278278
* Add ``d`` to :data:`sys.abiflags`.
279279
* Add :func:`sys.gettotalrefcount` function.
280280
* Add :option:`-X showrefcount <-X>` command line option.
281-
* Add :envvar:`PYTHONTHREADDEBUG` environment variable.
282281
* Add support for the ``__lltrace__`` variable: enable low-level tracing in the
283282
bytecode evaluation loop if the variable is defined.
284283
* Install :ref:`debug hooks on memory allocators <default-memory-allocators>`

Lib/test/test_threading.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -945,16 +945,6 @@ def noop(): pass
945945
threading.Thread(target=noop).start()
946946
# Thread.join() is not called
947947

948-
@unittest.skipUnless(Py_DEBUG, 'need debug build (Py_DEBUG)')
949-
def test_debug_deprecation(self):
950-
# bpo-44584: The PYTHONTHREADDEBUG environment variable is deprecated
951-
rc, out, err = assert_python_ok("-Wdefault", "-c", "pass",
952-
PYTHONTHREADDEBUG="1")
953-
msg = (b'DeprecationWarning: The threading debug '
954-
b'(PYTHONTHREADDEBUG environment variable) '
955-
b'is deprecated and will be removed in Python 3.12')
956-
self.assertIn(msg, err)
957-
958948
def test_import_from_another_thread(self):
959949
# bpo-1596321: If the threading module is first import from a thread
960950
# different than the main thread, threading._shutdown() must handle
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The deprecated debug build only ``PYTHONTHREADDEBUG`` environment variable
2+
no longer does anything.

Misc/python.man

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,6 @@ can be set to the callable of your debugger of choice.
560560
Setting these variables only has an effect in a debug build of Python, that is,
561561
if Python was configured with the
562562
\fB\--with-pydebug\fP build option.
563-
.IP PYTHONTHREADDEBUG
564-
If this environment variable is set, Python will print threading debug info.
565-
The feature is deprecated in Python 3.10 and will be removed in Python 3.12.
566563
.IP PYTHONDUMPREFS
567564
If this environment variable is set, Python will dump objects and reference
568565
counts still alive after shutting down the interpreter.

Python/pylifecycle.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,6 @@ pyinit_main_reconfigure(PyThreadState *tstate)
10911091
static PyStatus
10921092
init_interp_main(PyThreadState *tstate)
10931093
{
1094-
extern void _PyThread_debug_deprecation(void);
1095-
10961094
assert(!_PyErr_Occurred(tstate));
10971095

10981096
PyStatus status;
@@ -1194,9 +1192,6 @@ init_interp_main(PyThreadState *tstate)
11941192
#endif
11951193
}
11961194

1197-
// Warn about PYTHONTHREADDEBUG deprecation
1198-
_PyThread_debug_deprecation();
1199-
12001195
assert(!_PyErr_Occurred(tstate));
12011196

12021197
return _PyStatus_OK();

Python/thread.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -42,57 +42,19 @@
4242

4343
#endif /* _POSIX_THREADS */
4444

45-
46-
#ifdef Py_DEBUG
47-
static int thread_debug = 0;
48-
# define dprintf(args) (void)((thread_debug & 1) && printf args)
49-
#else
50-
# define dprintf(args)
51-
#endif
52-
5345
static int initialized;
5446

5547
static void PyThread__init_thread(void); /* Forward */
5648

5749
void
5850
PyThread_init_thread(void)
5951
{
60-
#ifdef Py_DEBUG
61-
const char *p = Py_GETENV("PYTHONTHREADDEBUG");
62-
63-
if (p) {
64-
if (*p)
65-
thread_debug = atoi(p);
66-
else
67-
thread_debug = 1;
68-
}
69-
#endif /* Py_DEBUG */
7052
if (initialized)
7153
return;
7254
initialized = 1;
73-
dprintf(("PyThread_init_thread called\n"));
7455
PyThread__init_thread();
7556
}
7657

77-
void
78-
_PyThread_debug_deprecation(void)
79-
{
80-
#ifdef Py_DEBUG
81-
if (thread_debug) {
82-
// Flush previous dprintf() logs
83-
fflush(stdout);
84-
if (PyErr_WarnEx(PyExc_DeprecationWarning,
85-
"The threading debug (PYTHONTHREADDEBUG environment "
86-
"variable) is deprecated and will be removed "
87-
"in Python 3.12",
88-
0))
89-
{
90-
_PyErr_WriteUnraisableMsg("at Python startup", NULL);
91-
}
92-
}
93-
#endif
94-
}
95-
9658
#if defined(_POSIX_THREADS)
9759
# define PYTHREAD_NAME "pthread"
9860
# include "thread_pthread.h"

Python/thread_nt.h

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
188188
unsigned threadID;
189189
callobj *obj;
190190

191-
dprintf(("%lu: PyThread_start_new_thread called\n",
192-
PyThread_get_thread_ident()));
193191
if (!initialized)
194192
PyThread_init_thread();
195193

@@ -209,14 +207,10 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
209207
* too many threads".
210208
*/
211209
int e = errno;
212-
dprintf(("%lu: PyThread_start_new_thread failed, errno %d\n",
213-
PyThread_get_thread_ident(), e));
214210
threadID = (unsigned)-1;
215211
HeapFree(GetProcessHeap(), 0, obj);
216212
}
217213
else {
218-
dprintf(("%lu: PyThread_start_new_thread succeeded: %p\n",
219-
PyThread_get_thread_ident(), (void*)hThread));
220214
CloseHandle(hThread);
221215
}
222216
return threadID;
@@ -257,7 +251,6 @@ PyThread_get_thread_native_id(void)
257251
void _Py_NO_RETURN
258252
PyThread_exit_thread(void)
259253
{
260-
dprintf(("%lu: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
261254
if (!initialized)
262255
exit(0);
263256
_endthreadex(0);
@@ -273,22 +266,17 @@ PyThread_allocate_lock(void)
273266
{
274267
PNRMUTEX aLock;
275268

276-
dprintf(("PyThread_allocate_lock called\n"));
277269
if (!initialized)
278270
PyThread_init_thread();
279271

280272
aLock = AllocNonRecursiveMutex() ;
281273

282-
dprintf(("%lu: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock));
283-
284274
return (PyThread_type_lock) aLock;
285275
}
286276

287277
void
288278
PyThread_free_lock(PyThread_type_lock aLock)
289279
{
290-
dprintf(("%lu: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
291-
292280
FreeNonRecursiveMutex(aLock) ;
293281
}
294282

@@ -333,9 +321,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock,
333321
milliseconds = INFINITE;
334322
}
335323

336-
dprintf(("%lu: PyThread_acquire_lock_timed(%p, %lld) called\n",
337-
PyThread_get_thread_ident(), aLock, microseconds));
338-
339324
if (aLock && EnterNonRecursiveMutex((PNRMUTEX)aLock,
340325
(DWORD)milliseconds) == WAIT_OBJECT_0) {
341326
success = PY_LOCK_ACQUIRED;
@@ -344,9 +329,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock aLock,
344329
success = PY_LOCK_FAILURE;
345330
}
346331

347-
dprintf(("%lu: PyThread_acquire_lock(%p, %lld) -> %d\n",
348-
PyThread_get_thread_ident(), aLock, microseconds, success));
349-
350332
return success;
351333
}
352334
int
@@ -358,10 +340,9 @@ PyThread_acq F438 uire_lock(PyThread_type_lock aLock, int waitflag)
358340
void
359341
PyThread_release_lock(PyThread_type_lock aLock)
360342
{
361-
dprintf(("%lu: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
362-
363-
if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
364-
dprintf(("%lu: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError()));
343+
if (aLock) {
344+
(void)LeaveNonRecursiveMutex((PNRMUTEX) aLock);
345+
}
365346
}
366347

367348
/* minimum/maximum thread stack sizes supported */

Python/thread_pthread.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
252252
size_t tss;
253253
#endif
254254

255-
dprintf(("PyThread_start_new_thread called\n"));
256255
if (!initialized)
257256
PyThread_init_thread();
258257

@@ -358,7 +357,6 @@ PyThread_get_thread_native_id(void)
358357
void _Py_NO_RETURN
359358
PyThread_exit_thread(void)
360359
{
361-
dprintf(("PyThread_exit_thread called\n"));
362360
if (!initialized)
363361
exit(0);
364362
pthread_exit(0);
@@ -376,7 +374,6 @@ PyThread_allocate_lock(void)
376374
sem_t *lock;
377375
int status, error = 0;
378376

379-
dprintf(("PyThread_allocate_lock called\n"));
380377
if (!initialized)
381378
PyThread_init_thread();
382379

@@ -392,7 +389,6 @@ PyThread_allocate_lock(void)
392389
}
393390
}
394391

395-
dprintf(("PyThread_allocate_lock() -> %p\n", (void *)lock));
396392
return (PyThread_type_lock)lock;
397393
}
398394

@@ -403,7 +399,6 @@ PyThread_free_lock(PyThread_type_lock lock)
403399
int status, error = 0;
404400

405401
(void) error; /* silence unused-but-set-variable warning */
406-
dprintf(("PyThread_free_lock(%p) called\n", lock));
407402

408403
if (!thelock)
409404
return;
@@ -435,8 +430,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
435430
int status, error = 0;
436431

437432
(void) error; /* silence unused-but-set-variable warning */
438-
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n",
439-
lock, microseconds, intr_flag));
440433

441434
_PyTime_t timeout; // relative timeout
442435
if (microseconds >= 0) {
@@ -544,8 +537,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
544537
success = PY_LOCK_FAILURE;
545538
}
546539

547-
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
548-
lock, microseconds, intr_flag, success));
549540
return success;
550541
}
551542

@@ -556,7 +547,6 @@ PyThread_release_lock(PyThread_type_lock lock)
556547
int status, error = 0;
557548

558549
(void) error; /* silence unused-but-set-variable warning */
559-
dprintf(("PyThread_release_lock(%p) called\n", lock));
560550

561551
status = sem_post(thelock);
562552
CHECK_STATUS("sem_post");
@@ -573,7 +563,6 @@ PyThread_allocate_lock(void)
573563
pthread_lock *lock;
574564
int status, error = 0;
575565

576-
dprintf(("PyThread_allocate_lock called\n"));
577566
if (!initialized)
578567
PyThread_init_thread();
579568

@@ -599,7 +588,6 @@ PyThread_allocate_lock(void)
599588
}
600589
}
601590

602-
dprintf(("PyThread_allocate_lock() -> %p\n", (void *)lock));
603591
return (PyThread_type_lock) lock;
604592
}
605593

@@ -610,7 +598,6 @@ PyThread_free_lock(PyThread_type_lock lock)
610598
int status, error = 0;
611599

612600
(void) error; /* silence unused-but-set-variable warning */
613-
dprintf(("PyThread_free_lock(%p) called\n", lock));
614601

615602
/* some pthread-like implementations tie the mutex to the cond
616603
* and must have the cond destroyed first.
@@ -632,9 +619,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
632619
pthread_lock *thelock = (pthread_lock *)lock;
633620
int status, error = 0;
634621

635-
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n",
636-
lock, microseconds, intr_flag));
637-
638622
if (microseconds == 0) {
639623
status = pthread_mutex_trylock( &thelock->mut );
640624
if (status != EBUSY)
@@ -694,8 +678,6 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
694678
}
695679

696680
if (error) success = PY_LOCK_FAILURE;
697-
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
698-
lock, microseconds, intr_flag, success));
699681
return success;
700682
}
701683

@@ -706,7 +688,6 @@ PyThread_release_lock(PyThread_type_lock lock)
706688
int status, error = 0;
707689

708690
(void) error; /* silence unused-but-set-variable warning */
709-
dprintf(("PyThread_release_lock(%p) called\n", lock));
710691

711692
status = pthread_mutex_lock( &thelock->mut );
712693
CHECK_STATUS_PTHREAD("pthread_mutex_lock[3]");

0 commit comments

Comments
 (0)
0