bpo-42251: Add gettrace and getprofile to threading (GH-23125)
This allows to retrieve the functions that were set in these two, which might differ from sys.gettrace and sys.getprofile within a thread.
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index 7eb12fe..e05486f 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -121,6 +121,17 @@
:meth:`~Thread.run` method is called.
+.. function:: gettrace()
+
+ .. index::
+ single: trace function
+ single: debugger
+
+ Get the trace function as set by :func:`settrace`.
+
+ .. versionadded:: 3.10
+
+
.. function:: setprofile(func)
.. index:: single: profile function
@@ -130,6 +141,15 @@
:meth:`~Thread.run` method is called.
+.. function:: getprofile()
+
+ .. index:: single: profile function
+
+ Get the profiler function as set by :func:`setprofile`.
+
+ .. versionadded:: 3.10
+
+
.. function:: stack_size([size])
Return the thread stack size used when creating new threads. The optional
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 60dee0c..89fc300 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -224,6 +224,14 @@
arguments passed to the Python executable.
(Contributed by Victor Stinner in :issue:`23427`.)
+threading
+---------
+
+Added :func:`threading.gettrace` and :func:`threading.getprofile` to
+retrieve the functions set by :func:`threading.settrace` and
+:func:`threading.setprofile` respectively.
+(Contributed by Mario Corchero in :issue:`42251`.)
+
types
-----