Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Doc/deprecations/pending-removal-in-3.21.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Pending removal in Python 3.21

* ``tempfile._TemporaryFileWrapper`` will be removed in Python 3.21. Use the
public :class:`tempfile.TemporaryFileWrapper` instead.

* :mod:`threading`:

* ``threading.Condition.notifyAll``, ``threading.Event.isSet``, and
``threading.activeCount`` will be removed in Python 3.21. Use the snake case
names (e.g., ``notify_all``) instead.
* ``threading.Thread.isDaemon``, ``threading.Thread.setDaemon`` will be removed
in Python 3.21. Use the property ``threading.Thread.daemon`` instead.
* ``threading.Thread.getName`` and ``threading.Thread.setName`` will be removed
in Python 3.21. Use the property ``threading.Thread.name`` instead.
10 changes: 10 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,16 @@ New deprecations
Use the new public :class:`tempfile.TemporaryFileWrapper` instead,
which is the return type of :func:`tempfile.NamedTemporaryFile`.

* :mod:`threading`:

* ``threading.Condition.notifyAll``, ``threading.Event.isSet``, and
``threading.activeCount`` will be removed in Python 3.21. Use the snake case
names (e.g., ``notify_all``) instead.
* ``threading.Thread.isDaemon``, ``threading.Thread.setDaemon`` will be removed
in Python 3.21. Use the property ``threading.Thread.daemon`` instead.
* ``threading.Thread.getName`` and ``threading.Thread.setName`` will be removed
in Python 3.21. Use the property ``threading.Thread.name`` instead.

* :mod:`tkinter`:

* :func:`tkinter.filedialog.askopenfiles` is deprecated and slated for
Expand Down
33 changes: 9 additions & 24 deletions Lib/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys as _sys
import _thread
import _contextvars
lazy import warnings

from time import monotonic as _time
from _weakrefset import WeakSet
Expand Down Expand Up @@ -444,9 +445,7 @@ def notifyAll(self):
This method is deprecated, use notify_all() instead.

"""
import warnings
warnings.warn('notifyAll() is deprecated, use notify_all() instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated("notifyAll", 'notifyAll() is deprecated, use notify_all() instead', remove=(3, 21))
self.notify_all()


Expand Down Expand Up @@ -616,9 +615,7 @@ def isSet(self):
This method is deprecated, use is_set() instead.

"""
import warnings
warnings.warn('isSet() is deprecated, use is_set() instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated("isSet", 'isSet() is deprecated, use is_set() instead', remove=(3, 21))
return self.is_set()

def set(self):
Expand Down Expand Up @@ -1352,9 +1349,7 @@ def isDaemon(self):
This method is deprecated, use the daemon attribute instead.

"""
import warnings
warnings.warn('isDaemon() is deprecated, get the daemon attribute instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated('isDaemon', 'isDaemon() is deprecated, get the daemon attribute instead',remove=(3,21))
return self.daemon

def setDaemon(self, daemonic):
Expand All @@ -1363,9 +1358,7 @@ def setDaemon(self, daemonic):
This method is deprecated, use the .daemon property instead.

"""
import warnings
warnings.warn('setDaemon() is deprecated, set the daemon attribute instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated('setDaemon', 'setDaemon() is deprecated, set the daemon attribute instead', remove=(3,21))
self.daemon = daemonic

def getName(self):
Expand All @@ -1374,9 +1367,7 @@ def getName(self):
This method is deprecated, use the name attribute instead.

"""
import warnings
warnings.warn('getName() is deprecated, get the name attribute instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated('getName', 'getName() is deprecated, get the name attribute instead', remove=(3,21))
return self.name

def setName(self, name):
Expand All @@ -1385,9 +1376,7 @@ def setName(self, name):
This method is deprecated, use the name attribute instead.

"""
import warnings
warnings.warn('setName() is deprecated, set the name attribute instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated('setName', 'setName() is deprecated, set the name attribute instead', remove=(3,21))
self.name = name


Expand Down Expand Up @@ -1621,9 +1610,7 @@ def currentThread():
This function is deprecated, use current_thread() instead.

"""
import warnings
warnings.warn('currentThread() is deprecated, use current_thread() instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated('currentThread', 'currentThread() is deprecated, use current_thread() instead', remove=(3,21))
return current_thread()

def active_count():
Expand All @@ -1644,9 +1631,7 @@ def activeCount():
This function is deprecated, use active_count() instead.

"""
import warnings
warnings.warn('activeCount() is deprecated, use active_count() instead',
DeprecationWarning, stacklevel=2)
warnings._deprecated('activeCount', 'activeCount() is deprecated, use active_count() instead', remove=(3,21))
return active_count()

def _enumerate():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The methods ``threading.Condition.notifyAll``, ``threading.Event.isSet``,
``threading.Thread.isDaemon``, ``threading.Thread.setDaemon``,
``threading.Thread.getName``, ``threading.Thread.setName``, and the function
``threading.activeCount``, which have been deprecated since Python 3.10, are
now scheduled for removal in Python 3.21.
Loading