8000 bpo-43723: deprecate camelCase aliases from threading by JelleZijlstra · Pull Request #25174 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-43723: deprecate camelCase aliases from threading #25174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
don't schedule removal, adjust docs
  • Loading branch information
JelleZijlstra committed Apr 7, 2021
commit 1af898e289e3b7175ecd79a0d1947f0338a29db2
14 changes: 7 additions & 7 deletions Doc/library/threading.rst
8000
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to say "deprecated" somewhere, rather than "still supported".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded



.. impl-detail::
Expand All @@ -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()
Expand All @@ -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.


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.


Expand Down Expand Up @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=======
Expand Down
14 changes: 7 additions & 7 deletions Lib/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
16 changes: 10 additions & 6 deletions Misc/NEWS.d/next/Library/2021-04-03-18-03-44.bpo-43723.uBhBZS.rst
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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` =& 8000 gt; :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.
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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do it a little differently to get the markup working and work around python/core-workflow#394.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to do it a little differently to get the markup working and work around python/core-workflow#394.

If you put each item on a long line, you should not be affected by https://github.com/python/core-workflow/issues/394 no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blurb reflows the lines to make them fit into 76 characters, so I have to make each line fit into 76 characters to avoid the bug.

0