From 558e66b06b8df04314a0d0d8ac317f580af30870 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 3 Apr 2021 18:04:40 -0700 Subject: [PATCH 1/7] bpo-43723: deprecate camelCase aliases from threading 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). --- Doc/faq/library.rst | 4 +- Doc/library/idle.rst | 2 +- Doc/library/threading.rst | 19 ++++- Lib/test/test_threading.py | 31 ++++++-- Lib/threading.py | 76 ++++++++++++++++++- .../2021-04-03-18-03-44.bpo-43723.uBhBZS.rst | 6 ++ 6 files changed, 121 insertions(+), 17 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst diff --git a/Doc/faq/library.rst b/Doc/faq/library.rst index 97058b5806a35c..4d27abd4351ec0 100644 --- a/Doc/faq/library.rst +++ b/Doc/faq/library.rst @@ -319,11 +319,11 @@ Here's a trivial example:: 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 6ef15653eacb55..3c302115b5f408 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -732,7 +732,7 @@ intended to be the same as executing the same code by the default method, 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 bb982f2edcf1b2..4162a251171894 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -16,9 +16,9 @@ level :mod:`_thread` module. See also the :mod:`queue` module. .. note:: - While they are not listed below, the ``camelCase`` names used for some + The ``camelCase`` names used for some methods and functions in this module in the Python 2.x series are still - supported by this module. + supported by this module. They will be removed in the future. .. impl-detail:: @@ -42,6 +42,8 @@ This module defines the following functions: Return the number of :class:`Thread` objects currently alive. The returned count is equal to the length of the list returned by :func:`.enumerate`. + .. deprecated-removed:: 3.10 3.12 + The function `activeCount` is an alias for this function. .. function:: current_thread() @@ -50,6 +52,9 @@ This module defines the following functions: :mod:`threading` module, a dummy thread object with limited functionality is returned. + .. deprecated-removed:: 3.10 3.12 + The function `currentThread` is an alias for this function. + .. function:: excepthook(args, /) @@ -384,6 +389,8 @@ since it is impossible to detect the termination of alien threads. Old getter/setter API for :attr:`~Thread.name`; use it directly as a property instead. + .. deprecated-removed:: 3.10 3.12 + .. attribute:: ident The 'thread identifier' of this thread or ``None`` if the thread has not @@ -436,6 +443,8 @@ since it is impossible to detect the termination of alien threads. Old getter/setter API for :attr:`~Thread.daemon`; use it directly as a property instead. + .. deprecated-removed:: 3.10 3.12 + .. _lock-objects: @@ -771,6 +780,9 @@ item to the buffer only needs to wake up one consumer thread. calling thread has not acquired the lock when this method is called, a :exc:`RuntimeError` is raised. + .. deprecated-removed:: 3.10 3.12 + The method `notifyAll` is an alias for this method. + .. _semaphore-objects: @@ -908,6 +920,9 @@ method. The :meth:`~Event.wait` method blocks until the flag is true. Return ``True`` if and only if the internal flag is true. + .. deprecated-removed:: 3.10 3.12 + The method `isSet` is an alias for this method. + .. method:: set() Set the internal flag to true. All threads waiting for it to become true diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 933935ba2ce2c8..77ae6dc832babd 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -154,9 +154,9 @@ def test_various_ops(self): def test_ident_of_no_threading_threads(self): # The ident still must work for the main thread and dummy threads. - self.assertIsNotNone(threading.currentThread().ident) + self.assertIsNotNone(threading.current_thread().ident) def f(): - ident.append(threading.currentThread().ident) + ident.append(threading.current_thread().ident) done.set() done = threading.Event() ident = [] @@ -447,13 +447,28 @@ def test_old_threading_api(self): # Just a quick sanity check to make sure the old method names are # still present t = threading.Thread() - t.isDaemon() - t.setDaemon(True) - t.getName() - t.setName("name") + with self.assertWarnsRegex(DeprecationWarning, r'use \.daemon'): + t.isDaemon() + with self.assertWarnsRegex(DeprecationWarning, r'use \.daemon'): + t.setDaemon(True) + with self.assertWarnsRegex(DeprecationWarning, r'use \.name'): + t.getName() + with self.assertWarnsRegex(DeprecationWarning, r'use \.name'): + t.setName("name") + e = threading.Event() - e.isSet() - threading.activeCount() + with self.assertWarnsRegex(DeprecationWarning, 'use is_set()'): + e.isSet() + + cond = threading.Condition() + cond.acquire() + with self.assertWarnsRegex(DeprecationWarning, 'use notify_all()'): + cond.notifyAll() + + with self.assertWarnsRegex(DeprecationWarning, 'use active_count()'): + threading.activeCount() + with self.assertWarnsRegex(DeprecationWarning, 'use current_thread()'): + threading.currentThread() def test_repr_daemon(self): t = threading.Thread() diff --git a/Lib/threading.py b/Lib/threading.py index ff2624a3e1e49e..50a6c9a6c0fbc4 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -388,7 +388,16 @@ def notify_all(self): """ self.notify(len(self._waiters)) - notifyAll = notify_all + def notifyAll(self): + """Wake up all threads waiting on this condition. + + This method is deprecated, use notify_all() instead. + + """ + import warnings + warnings.warn('notifyAll() is deprecated, use notify_all() instead', + DeprecationWarning, stacklevel=2) + self.notify_all() class Semaphore: @@ -538,7 +547,16 @@ def is_set(self): """Return true if and only if the internal flag is true.""" return self._flag - isSet = is_set + def isSet(self): + """Return true if and only if the internal flag is true. + + This method is deprecated, use notify_all() instead. + + """ + import warnings + warnings.warn('isSet() is deprecated, use is_set() instead', + DeprecationWarning, stacklevel=2) + return self.is_set() def set(self): """Set the internal flag to true. @@ -1146,15 +1164,47 @@ def daemon(self, daemonic): self._daemonic = daemonic def isDaemon(self): + """Return whether this thread is a daemon. + + This method is deprecated, use the .daemon property instead. + + """ + import warnings + warnings.warn('isDaemon() is deprecated, use .daemon instead', + DeprecationWarning, stacklevel=2) return self.daemon def setDaemon(self, daemonic): + """Set whether this thread is a daemon. + + This method is deprecated, use the .daemon property instead. + + """ + import warnings + warnings.warn('setDaemon() is deprecated, use .daemon instead', + DeprecationWarning, stacklevel=2) self.daemon = daemonic def getName(self): + """Return a string used for identification purposes only. + + This method is deprecated, use the .name property instead. + + """ + import warnings + warnings.warn('getName() is deprecated, use .name instead', + DeprecationWarning, stacklevel=2) return self.name def setName(self, name): + """Set the name string for this thread. + + This method is deprecated, use the .name property instead. + + """ + import warnings + warnings.warn('setName() is deprecated, use .name instead', + DeprecationWarning, stacklevel=2) self.name = name @@ -1349,7 +1399,16 @@ def current_thread(): except KeyError: return _DummyThread() -currentThread = current_thread +def currentThread(): + """Return the current Thread object, corresponding to the caller's thread of control. + + This function is deprecated, use current_thread() instead. + + """ + import warnings + warnings.warn('currentThread() is deprecated, use current_thread() instead', + DeprecationWarning, stacklevel=2) + return current_thread() def active_count(): """Return the number of Thread objects currently alive. @@ -1361,7 +1420,16 @@ def active_count(): with _active_limbo_lock: return len(_active) + len(_limbo) -activeCount = active_count +def activeCount(): + """Return the number of Thread objects currently alive. + + This function is deprecated, use active_count() instead. + + """ + import warnings + warnings.warn('activeCount() is deprecated, use active_count() instead', + DeprecationWarning, stacklevel=2) + return active_count() def _enumerate(): # Same as enumerate(), but without the lock. Internal use only. diff --git a/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst new file mode 100644 index 00000000000000..fa958237ca6d03 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst @@ -0,0 +1,6 @@ +The following `threading` methods are now deprecated: +`threading.currentThread`, `threading.activeCount`, +`threading.Condition.notifyAll`, `threading.Event.isSet`, +`threading.Thread.setName`, `threading.thread.getName`, +`threading.Thread.isDaemon`, and `threading.Thread.setDaemon`. Patch by +Jelle Zijlstra. From 1af898e289e3b7175ecd79a0d1947f0338a29db2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 6 Apr 2021 19:55:27 -0700 Subject: [PATCH 2/7] don't schedule removal, adjust docs --- Doc/library/threading.rst | 14 +++++++------- Doc/whatsnew/3.10.rst | 11 +++++++++++ Lib/threading.py | 14 +++++++------- .../2021-04-03-18-03-44.bpo-43723.uBhBZS.rst | 16 ++++++++++------ 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index 4162a251171894..b9fc45c57303bd 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -18,7 +18,7 @@ level :mod:`_thread` module. See also the :mod:`queue` module. The ``camelCase`` names used for some methods and functions in this module in the Python 2.x series are still - supported by this module. They will be removed in the future. + supported by this module for compatibility with Python 2.5 and lower. .. impl-detail:: @@ -42,7 +42,7 @@ This module defines the following functions: Return the number of :class:`Thread` objects currently alive. The returned count is equal to the length of the list returned by :func:`.enumerate`. - .. deprecated-removed:: 3.10 3.12 + .. deprecated:: 3.10 The function `activeCount` is an alias for this function. .. function:: current_thread() @@ -52,7 +52,7 @@ This module defines the following functions: :mod:`threading` module, a dummy thread object with limited functionality is returned. - .. deprecated-removed:: 3.10 3.12 + .. deprecated:: 3.10 The function `currentThread` is an alias for this function. @@ -389,7 +389,7 @@ since it is impossible to detect the termination of alien threads. Old getter/setter API for :attr:`~Thread.name`; use it directly as a property instead. - .. deprecated-removed:: 3.10 3.12 + .. deprecated:: 3.10 .. attribute:: ident @@ -443,7 +443,7 @@ since it is impossible to detect the termination of alien threads. Old getter/setter API for :attr:`~Thread.daemon`; use it directly as a property instead. - .. deprecated-removed:: 3.10 3.12 + .. deprecated:: 3.10 .. _lock-objects: @@ -780,7 +780,7 @@ item to the buffer only needs to wake up one consumer thread. calling thread has not acquired the lock when this method is called, a :exc:`RuntimeError` is raised. - .. deprecated-removed:: 3.10 3.12 + .. deprecated:: 3.10 The method `notifyAll` is an alias for this method. @@ -920,7 +920,7 @@ method. The :meth:`~Event.wait` method blocks until the flag is true. Return ``True`` if and only if the internal flag is true. - .. deprecated-removed:: 3.10 3.12 + .. deprecated:: 3.10 The method `isSet` is an alias for this method. .. method:: set() diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index ea2834bc761457..9a6b8f0e1ec93e 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1070,6 +1070,17 @@ Deprecated ``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 ======= diff --git a/Lib/threading.py b/Lib/threading.py index 50a6c9a6c0fbc4..4dcf84715c439d 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -1166,11 +1166,11 @@ def daemon(self, daemonic): def isDaemon(self): """Return whether this thread is a daemon. - This method is deprecated, use the .daemon property instead. + This method is deprecated, use the daemon attribute instead. """ import warnings - warnings.warn('isDaemon() is deprecated, use .daemon instead', + warnings.warn('isDaemon() is deprecated, get the daemon attribute instead', DeprecationWarning, stacklevel=2) return self.daemon @@ -1181,29 +1181,29 @@ def setDaemon(self, daemonic): """ import warnings - warnings.warn('setDaemon() is deprecated, use .daemon instead', + warnings.warn('setDaemon() is deprecated, set the daemon attribute instead', DeprecationWarning, stacklevel=2) self.daemon = daemonic def getName(self): """Return a string used for identification purposes only. - This method is deprecated, use the .name property instead. + This method is deprecated, use the name attribute instead. """ import warnings - warnings.warn('getName() is deprecated, use .name instead', + warnings.warn('getName() is deprecated, get the name attribute instead', DeprecationWarning, stacklevel=2) return self.name def setName(self, name): """Set the name string for this thread. - This method is deprecated, use the .name property instead. + This method is deprecated, use the name attribute instead. """ import warnings - warnings.warn('setName() is deprecated, use .name instead', + warnings.warn('setName() is deprecated, set the name attribute instead', DeprecationWarning, stacklevel=2) self.name = name diff --git a/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst index fa958237ca6d03..aedaf1b2347fda 100644 --- a/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst +++ b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst @@ -1,6 +1,10 @@ -The following `threading` methods are now deprecated: -`threading.currentThread`, `threading.activeCount`, -`threading.Condition.notifyAll`, `threading.Event.isSet`, -`threading.Thread.setName`, `threading.thread.getName`, -`threading.Thread.isDaemon`, and `threading.Thread.setDaemon`. Patch by -Jelle Zijlstra. +The following `threading` methods are now deprecated and should be replaced: +`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`. +Patch by Jelle Zijlstra. From a76261a1b6a30bd2787878fb7e609f61dae15119 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 6 Apr 2021 20:53:06 -0700 Subject: [PATCH 3/7] update tests --- Lib/test/test_threading.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 77ae6dc832babd..49a4af8365afce 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -447,13 +447,17 @@ def test_old_threading_api(self): # Just a quick sanity check to make sure the old method names are # still present t = threading.Thread() - with self.assertWarnsRegex(DeprecationWarning, r'use \.daemon'): + with self.assertWarnsRegex(DeprecationWarning, + r'get the daemon attribute'): t.isDaemon() - with self.assertWarnsRegex(DeprecationWarning, r'use \.daemon'): + with self.assertWarnsRegex(DeprecationWarning, + r'set the daemon attribute'): t.setDaemon(True) - with self.assertWarnsRegex(DeprecationWarning, r'use \.name'): + with self.assertWarnsRegex(DeprecationWarning, + r'get the name attribute'): t.getName() - with self.assertWarnsRegex(DeprecationWarning, r'use \.name'): + with self.assertWarnsRegex(DeprecationWarning, + r'set the name attribute'): t.setName("name") e = threading.Event() From b32c41eb76fcb4e4f80155c2932bc889a2399244 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 7 Apr 2021 20:45:08 -0700 Subject: [PATCH 4/7] more doc updates --- Doc/library/threading.rst | 20 +++++--------- Doc/whatsnew/3.10.rst | 26 +++++++++++++------ .../2021-04-03-18-03-44.bpo-43723.uBhBZS.rst | 25 ++++++++++++------ 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index b9fc45c57303bd..9b15e465544340 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -42,8 +42,7 @@ This module defines the following functions: Return the number of :class:`Thread` objects currently alive. The returned count is equal to the length of the list returned by :func:`.enumerate`. - .. deprecated:: 3.10 - The function `activeCount` is an alias for this function. + The function `activeCount` is a deprecated alias for this function. .. function:: current_thread() @@ -52,8 +51,7 @@ This module defines the following functions: :mod:`threading` module, a dummy thread object with limited functionality is returned. - .. deprecated:: 3.10 - The function `currentThread` is an alias for this function. + The function `currentThread` is a deprecated alias for this function. .. function:: excepthook(args, /) @@ -386,11 +384,9 @@ since it is impossible to detect the termination of alien threads. .. 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 @@ -440,11 +436,9 @@ since it is impossible to detect the termination of alien threads. .. 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: @@ -780,8 +774,7 @@ item to the buffer only needs to wake up one consumer thread. calling thread has not acquired the lock when this method is called, a :exc:`RuntimeError` is raised. - .. deprecated:: 3.10 - The method `notifyAll` is an alias for this method. + The method `notifyAll` is a deprecated alias for this method. .. _semaphore-objects: @@ -920,8 +913,7 @@ method. The :meth:`~Event.wait` method blocks until the flag is true. Return ``True`` if and only if the internal flag is true. - .. deprecated:: 3.10 - The method `isSet` is an alias for this method. + The method `isSet` is a deprecated alias for this method. .. method:: set() diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 9a6b8f0e1ec93e..154cca8633eead 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1071,14 +1071,24 @@ Deprecated (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`. + + * `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`.) diff --git a/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst index aedaf1b2347fda..054f44c38064aa 100644 --- a/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst +++ b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst @@ -1,10 +1,19 @@ The following `threading` methods are now deprecated and should be replaced: -`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`. + +- `currentThread` => :func:`threading.current_thread` + +- `activeCount` => :func:`threading.active_count` + +- `Condition.notifyAll` => :meth:`threading.Condition.notify_all` + +- `Event.isSet` => :meth:`threading.Event.is_set` + +- `Thread.setName` => :attr:`threading.Thread.name` + +- `thread.getName` => :attr:`threading.Thread.name` + +- `Thread.isDaemon` => :attr:`threading.Thread.daemon` + +- `Thread.setDaemon` => :attr:`threading.Thread.daemon` + Patch by Jelle Zijlstra. From be7c522c7770538a8f3687e420c433d13c388b6d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 7 Apr 2021 21:02:58 -0700 Subject: [PATCH 5/7] fix make check --- Doc/library/threading.rst | 9 +++++---- Doc/whatsnew/3.10.rst | 18 +++++++++--------- .../2021-04-03-18-03-44.bpo-43723.uBhBZS.rst | 18 +++++++++--------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index 9b15e465544340..6b29c18ebf92f3 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -42,7 +42,8 @@ This module defines the following functions: 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. + The function ``activeCount`` is a deprecated alias for this function. + .. function:: current_thread() @@ -51,7 +52,7 @@ This module defines the following functions: :mod:`threading` module, a dummy thread object with limited functionality is returned. - The function `currentThread` is a deprecated alias for this function. + The function ``currentThread`` is a deprecated alias for this function. .. function:: excepthook(args, /) @@ -774,7 +775,7 @@ item to the buffer only needs to wake up one consumer thread. 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. + The method ``notifyAll`` is a deprecated alias for this method. .. _semaphore-objects: @@ -913,7 +914,7 @@ method. The :meth:`~Event.wait` method blocks until the flag is true. Return ``True`` if and only if the internal flag is true. - The method `isSet` is a deprecated alias for this method. + The method ``isSet`` is a deprecated alias for this method. .. method:: set() diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index 154cca8633eead..8fa253f754ad0f 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1070,24 +1070,24 @@ Deprecated ``cache=shared`` query parameter. (Contributed by Erlend E. Aasland in :issue:`24464`.) -* The following `threading` methods are now deprecated: +* The following ``threading`` methods are now deprecated: - * `threading.currentThread` => :func:`threading.current_thread` + * ``threading.currentThread`` => :func:`threading.current_thread` - * `threading.activeCount` => :func:`threading.active_count` + * ``threading.activeCount`` => :func:`threading.active_count` - * `threading.Condition.notifyAll` => + * ``threading.Condition.notifyAll`` => :meth:`threading.Condition.notify_all` - * `threading.Event.isSet` => :meth:`threading.Event.is_set` + * ``threading.Event.isSet`` => :meth:`threading.Event.is_set` - * `threading.Thread.setName` => :attr:`threading.Thread.name` + * ``threading.Thread.setName`` => :attr:`threading.Thread.name` - * `threading.thread.getName` => :attr:`threading.Thread.name` + * ``threading.thread.getName`` => :attr:`threading.Thread.name` - * `threading.Thread.isDaemon` => :attr:`threading.Thread.daemon` + * ``threading.Thread.isDaemon`` => :attr:`threading.Thread.daemon` - * `threading.Thread.setDaemon` => :attr:`threading.Thread.daemon` + * ``threading.Thread.setDaemon`` => :attr:`threading.Thread.daemon` (Contributed by Jelle Zijlstra in :issue:`21574`.) diff --git a/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst index 054f44c38064aa..27cf7aa716273c 100644 --- a/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst +++ b/Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst @@ -1,19 +1,19 @@ -The following `threading` methods are now deprecated and should be replaced: +The following ``threading`` methods are now deprecated and should be replaced: -- `currentThread` => :func:`threading.current_thread` +- ``currentThread`` => :func:`threading.current_thread` -- `activeCount` => :func:`threading.active_count` +- ``activeCount`` => :func:`threading.active_count` -- `Condition.notifyAll` => :meth:`threading.Condition.notify_all` +- ``Condition.notifyAll`` => :meth:`threading.Condition.notify_all` -- `Event.isSet` => :meth:`threading.Event.is_set` +- ``Event.isSet`` => :meth:`threading.Event.is_set` -- `Thread.setName` => :attr:`threading.Thread.name` +- ``Thread.setName`` => :attr:`threading.Thread.name` -- `thread.getName` => :attr:`threading.Thread.name` +- ``thread.getName`` => :attr:`threading.Thread.name` -- `Thread.isDaemon` => :attr:`threading.Thread.daemon` +- ``Thread.isDaemon`` => :attr:`threading.Thread.daemon` -- `Thread.setDaemon` => :attr:`threading.Thread.daemon` +- ``Thread.setDaemon`` => :attr:`threading.Thread.daemon` Patch by Jelle Zijlstra. From 8fac0278beedbad99823b4f21de15a3712a5dd63 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 8 Apr 2021 17:49:37 -0700 Subject: [PATCH 6/7] reword more docs --- Doc/library/threading.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index 6b29c18ebf92f3..cf1688cfaa404e 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -16,9 +16,9 @@ level :mod:`_thread` module. See also the :mod:`queue` module. .. note:: - The ``camelCase`` names used for some - methods and functions in this module in the Python 2.x series are still - supported by this module for compatibility with Python 2.5 and lower. + 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:: @@ -388,6 +388,8 @@ since it is impossible to detect the termination of alien threads. 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 @@ -440,6 +442,8 @@ since it is impossible to detect the termination of alien threads. Deprecated getter/setter API for :attr:`~Thread.daemon`; use it directly as a property instead. + .. deprecated: 3.10 + .. _lock-objects: From aeae84745c74205bb670e568fa603e99344a3707 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 8 Apr 2021 20:53:20 -0700 Subject: [PATCH 7/7] fix directives --- Doc/library/threading.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index cf1688cfaa404e..16f23c3a0c3548 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -388,7 +388,7 @@ since it is impossible to detect the termination of alien threads. Deprecated getter/setter API for :attr:`~Thread.name`; use it directly as a property instead. - .. deprecated: 3.10 + .. deprecated:: 3.10 .. attribute:: ident @@ -442,7 +442,7 @@ since it is impossible to detect the termination of alien threads. Deprecated getter/setter API for :attr:`~Thread.daemon`; use it directly as a property instead. - .. deprecated: 3.10 + .. deprecated:: 3.10 .. _lock-objects: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy