| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 938e84b commit 4d77691
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -962,10 +962,12 @@ Debug-mode variables | |||
| 962 | 962 | ||
| 963 | 963 | .. envvar:: PYTHONTHREADDEBUG | |
| 964 | 964 | ||
| 965 | - If set, Python will print threading debug info. | ||
| 965 | + If set, Python will print threading debug info into stdout. | ||
| 966 | 966 | ||
| 967 | 967 | Need a :ref:`debug build of Python <debug-build>`. | |
| 968 | 968 | ||
| 969 | + .. deprecated-removed:: 3.10 3.12 | ||
| 970 | + | ||
| 969 | 971 | ||
| 970 | 972 | .. envvar:: PYTHONDUMPREFS | |
| 971 | 973 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1691,6 +1691,11 @@ Deprecated | |||
| 1691 | 1691 | * NPN features like :meth:`ssl.SSLSocket.selected_npn_protocol` and | |
| 1692 | 1692 | :meth:`ssl.SSLContext.set_npn_protocols` are replaced by ALPN. | |
| 1693 | 1693 | ||
| 1694 | + * The threading debug (:envvar:`PYTHONTHREADDEBUG` environment variable) is | ||
| 1695 | + deprecated in Python 3.10 and will be removed in Python 3.12. This feature | ||
| 1696 | + requires a :ref:`debug build of Python <debug-build>`. | ||
| 1697 | + (Contributed by Victor Stinner in :issue:`44584`.) | ||
| 1698 | + | ||
| 1694 | 1699 | .. _whatsnew310-removed: | |
| 1695 | 1700 | ||
| 1696 | 1701 | Removed | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,9 @@ | |||
| 32 | 32 | # on platforms known to behave badly. | |
| 33 | 33 | platforms_to_skip = ('netbsd5', 'hp-ux11') | |
| 34 | 34 | ||
| 35 | + # Is Python built with Py_DEBUG macro defined? | ||
| 36 | + Py_DEBUG = hasattr(sys, 'gettotalrefcount') | ||
| 37 | + | ||
| 35 | 38 | ||
| 36 | 39 | def restore_default_excepthook(testcase): | |
| 37 | 40 | testcase.addCleanup(setattr, threading, 'excepthook', threading.excepthook) | |
@@ -915,6 +918,16 @@ def noop(): pass | |||
| 915 | 918 | threading.Thread(target=noop).start() | |
| 916 | 919 | # Thread.join() is not called | |
| 917 | 920 | ||
| 921 | + @unittest.skipUnless(Py_DEBUG, 'need debug build (Py_DEBUG)') | ||
| 922 | + def test_debug_deprecation(self): | ||
| 923 | + # bpo-44584: The PYTHONTHREADDEBUG environment variable is deprecated | ||
| 924 | + rc, out, err = assert_python_ok("-Wdefault", "-c", "pass", | ||
| 925 | + PYTHONTHREADDEBUG="1") | ||
| 926 | + msg = (b'DeprecationWarning: The threading debug ' | ||
| 927 | + b'(PYTHONTHREADDEBUG environment variable) ' | ||
| 928 | + b'is deprecated and will be removed in Python 3.12') | ||
| 929 | + self.assertIn(msg, err) | ||
| 930 | + | ||
| 918 | 931 | ||
| 919 | 932 | class ThreadJoinOnShutdown(BaseTestCase): | |
| 920 | 933 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + The threading debug (:envvar:`PYTHONTHREADDEBUG` environment variable) is | ||
| 2 | + deprecated in Python 3.10 and will be removed in Python 3.12. This feature | ||
| 3 | + requires a debug build of Python. Patch by Victor Stinner. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -550,6 +550,7 @@ if Python was configured with the | |||
| 550 | 550 | \fB\--with-pydebug\fP build option. | |
| 551 | 551 | .IP PYTHONTHREADDEBUG | |
| 552 | 552 | If this environment variable is set, Python will print threading debug info. | |
| 553 | + The feature is deprecated in Python 3.10 and will be removed in Python 3.12. | ||
| 553 | 554 | .IP PYTHONDUMPREFS | |
| 554 | 555 | If this environment variable is set, Python will dump objects and reference | |
| 555 | 556 | counts still alive after shutting down the interpreter. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1057,6 +1057,8 @@ pyinit_main_reconfigure(PyThreadState *tstate) | |||
| 1057 | 1057 | static PyStatus | |
| 1058 | 1058 | init_interp_main(PyThreadState *tstate) | |
| 1059 | 1059 | { | |
| 1060 | + extern void _PyThread_debug_deprecation(void); | ||
| 1061 | + | ||
| 1060 | 1062 | assert(!_PyErr_Occurred(tstate)); | |
| 1061 | 1063 | ||
| 1062 | 1064 | PyStatus status; | |
@@ -1158,6 +1160,9 @@ init_interp_main(PyThreadState *tstate) | |||
| 1158 | 1160 | #endif | |
| 1159 | 1161 | } | |
| 1160 | 1162 | ||
| 1163 | + // Warn about PYTHONTHREADDEBUG deprecation | ||
| 1164 | + _PyThread_debug_deprecation(); | ||
| 1165 | + | ||
| 1161 | 1166 | assert(!_PyErr_Occurred(tstate)); | |
| 1162 | 1167 | ||
| 1163 | 1168 | return _PyStatus_OK(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,25 @@ PyThread_init_thread(void) | |||
| 75 | 75 | PyThread__init_thread(); | |
| 76 | 76 | } | |
| 77 | 77 | ||
| 78 | + void | ||
| 79 | + _PyThread_debug_deprecation(void) | ||
| 80 | + { | ||
| 81 | + #ifdef Py_DEBUG | ||
| 82 | + if (thread_debug) { | ||
| 83 | + // Flush previous dprintf() logs | ||
| 84 | + fflush(stdout); | ||
| 85 | + if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| 86 | + "The threading debug (PYTHONTHREADDEBUG environment " | ||
| 87 | + "variable) is deprecated and will be removed " | ||
| 88 | + "in Python 3.12", | ||
| 89 | + 0)) | ||
| 90 | + { | ||
| 91 | + _PyErr_WriteUnraisableMsg("at Python startup", NULL); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + #endif | ||
| 95 | + } | ||
| 96 | + | ||
| 78 | 97 | #if defined(_POSIX_THREADS) | |
| 79 | 98 | # define PYTHREAD_NAME "pthread" | |
| 80 | 99 | # include "thread_pthread.h" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments