bpo-43723: Deprecate camelCase aliases from threading (GH-25174)
The snake_case names have existed since Python 2.6, so there is
no reason to keep the old camelCase names around. One similar
method, threading.Thread.isAlive, was already removed in
Python 3.9 (bpo-37804).
diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst
index 97058b5..4d27abd 100644
--- a/Doc/faq/library.rst
+++ b/Doc/faq/library.rst
@@ -319,11 +319,11 @@
try:
arg = q.get(block=False)
except queue.Empty:
- print('Worker', threading.currentThread(), end=' ')
+ print('Worker', threading.current_thread(), end=' ')
print('queue empty')
break
else:
- print('Worker', threading.currentThread(), end=' ')
+ print('Worker', threading.current_thread(), end=' ')
print('running with argument', arg)
time.sleep(0.5)
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index 6ef1565..3c30211 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -732,7 +732,7 @@
directly with Python in a text-mode system console or terminal window.
However, the different interface and operation occasionally affect
visible results. For instance, ``sys.modules`` starts with more entries,
-and ``threading.activeCount()`` returns 2 instead of 1.
+and ``threading.active_count()`` returns 2 instead of 1.
By default, IDLE runs user code in a separate OS process rather than in
the user interface process that runs the shell and editor. In the execution
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index bb982f2..16f23c3 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -16,9 +16,9 @@
.. note::
- While they are not listed below, the ``camelCase`` names used for some
- methods and functions in this module in the Python 2.x series are still
- supported by this module.
+ In the Python 2.x series, this module contained ``camelCase`` names
+ for some methods and functions. These are deprecated as of Python 3.10,
+ but they are still supported for compatibility with Python 2.5 and lower.
.. impl-detail::
@@ -42,6 +42,8 @@
Return the number of :class:`Thread` objects currently alive. The returned
count is equal to the length of the list returned by :func:`.enumerate`.
+ The function ``activeCount`` is a deprecated alias for this function.
+
.. function:: current_thread()
@@ -50,6 +52,8 @@
:mod:`threading` module, a dummy thread object with limited functionality is
returned.
+ The function ``currentThread`` is a deprecated alias for this function.
+
.. function:: excepthook(args, /)
@@ -381,9 +385,11 @@
.. method:: getName()
setName()
- Old getter/setter API for :attr:`~Thread.name`; use it directly as a
+ Deprecated getter/setter API for :attr:`~Thread.name`; use it directly as a
property instead.
+ .. deprecated:: 3.10
+
.. attribute:: ident
The 'thread identifier' of this thread or ``None`` if the thread has not
@@ -433,9 +439,11 @@
.. method:: isDaemon()
setDaemon()
- Old getter/setter API for :attr:`~Thread.daemon`; use it directly as a
+ Deprecated getter/setter API for :attr:`~Thread.daemon`; use it directly as a
property instead.
+ .. deprecated:: 3.10
+
.. _lock-objects:
@@ -771,6 +779,8 @@
calling thread has not acquired the lock when this method is called, a
:exc:`RuntimeError` is raised.
+ The method ``notifyAll`` is a deprecated alias for this method.
+
.. _semaphore-objects:
@@ -908,6 +918,8 @@
Return ``True`` if and only if the internal flag is true.
+ The method ``isSet`` is a deprecated alias for this method.
+
.. method:: set()
Set the internal flag to true. All threads waiting for it to become true
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 9f6b7a4..85f229c 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -1129,6 +1129,27 @@
``cache=shared`` query parameter.
(Contributed by Erlend E. Aasland in :issue:`24464`.)
+* The following ``threading`` methods are now deprecated:
+
+ * ``threading.currentThread`` => :func:`threading.current_thread`
+
+ * ``threading.activeCount`` => :func:`threading.active_count`
+
+ * ``threading.Condition.notifyAll`` =>
+ :meth:`threading.Condition.notify_all`
+
+ * ``threading.Event.isSet`` => :meth:`threading.Event.is_set`
+
+ * ``threading.Thread.setName`` => :attr:`threading.Thread.name`
+
+ * ``threading.thread.getName`` => :attr:`threading.Thread.name`
+
+ * ``threading.Thread.isDaemon`` => :attr:`threading.Thread.daemon`
+
+ * ``threading.Thread.setDaemon`` => :attr:`threading.Thread.daemon`
+
+ (Contributed by Jelle Zijlstra in :issue:`21574`.)
+
Removed
=======