mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
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 4d77691172
)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
0a642d5773
commit
a11158ecef
7 changed files with 49 additions and 1 deletions
|
@ -1057,6 +1057,8 @@ pyinit_main_reconfigure(PyThreadState *tstate)
|
|||
static PyStatus
|
||||
init_interp_main(PyThreadState *tstate)
|
||||
{
|
||||
extern void _PyThread_debug_deprecation(void);
|
||||
|
||||
assert(!_PyErr_Occurred(tstate));
|
||||
|
||||
PyStatus status;
|
||||
|
@ -1158,6 +1160,9 @@ init_interp_main(PyThreadState *tstate)
|
|||
#endif
|
||||
}
|
||||
|
||||
// Warn about PYTHONTHREADDEBUG deprecation
|
||||
_PyThread_debug_deprecation();
|
||||
|
||||
assert(!_PyErr_Occurred(tstate));
|
||||
|
||||
return _PyStatus_OK();
|
||||
|
|
|
@ -75,6 +75,25 @@ PyThread_init_thread(void)
|
|||
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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue