Skip to content
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

gh-105376: Remove logging.Logger.warn() method #105377

Merged
merged 1 commit into from
Jun 6, 2023
Merged
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
8 changes: 4 additions & 4 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ is the module's name in the Python package namespace.
.. versionchanged:: 3.8
The *stacklevel* parameter was added.

.. versionchanged:: 3.13
Remove the undocumented ``warn()`` method which was an alias to the
:meth:`warning` method.


.. method:: Logger.info(msg, *args, **kwargs)

Expand All @@ -287,10 +291,6 @@ is the module's name in the Python package namespace.
Logs a message with level :const:`WARNING` on this logger. The arguments are
interpreted as for :meth:`debug`.

.. note:: There is an obsolete method ``warn`` which is functionally
identical to ``warning``. As ``warn`` is deprecated, please do not use
it - use ``warning`` instead.

.. method:: Logger.error(msg, *args, **kwargs)

Logs a message with level :const:`ERROR` on this logger. The arguments are
Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ Removed
use ``locale.setlocale(locale.LC_ALL, "")`` instead.
(Contributed by Victor Stinner in :gh:`104783`.)

* Remove the undocumented and untested ``logging.Logger.warn()`` method,
deprecated since Python 3.3, which was an alias to the
:meth:`logging.Logger.warning` method: use the :meth:`logging.Logger.warning`
method instead.
(Contributed by Victor Stinner in :gh:`105376`.)


Porting to Python 3.13
======================
Expand Down
5 changes: 0 additions & 5 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,11 +1550,6 @@ def warning(self, msg, *args, **kwargs):
if self.isEnabledFor(WARNING):
self._log(WARNING, msg, args, **kwargs)

def warn(self, msg, *args, **kwargs):
warnings.warn("The 'warn' method is deprecated, "
"use 'warning' instead", DeprecationWarning, 2)
self.warning(msg, *args, **kwargs)

def error(self, msg, *args, **kwargs):
"""
Log 'msg % args' with severity 'ERROR'.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Remove the undocumented and untested ``logging.Logger.warn()`` method,
deprecated since Python 3.3, which was an alias to the
:meth:`logging.Logger.warning` method: use the :meth:`logging.Logger.warning`
method instead. Patch by Victor Stinner.