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.warn() and LoggerAdapter.warn() #106553

Merged
merged 2 commits into from
Jul 9, 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: 8 additions & 0 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,10 @@ interchangeably.
Attribute :attr:`manager` and method :meth:`_log` were added, which
delegate to the underlying logger and allow adapters to be nested.

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


Thread Safety
-------------
Expand Down Expand Up @@ -1162,6 +1166,10 @@ functions.
identical to ``warning``. As ``warn`` is deprecated, please do not use
it - use ``warning`` instead.

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


.. function:: error(msg, *args, **kwargs)

Expand Down
9 changes: 5 additions & 4 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,11 @@ 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.
* :mod:`logging`: Remove undocumented and untested ``Logger.warn()`` and
``LoggerAdapter.warn()`` methods and ``logging.warn()`` function. Deprecated
since Python 3.3, they were aliases to the :meth:`logging.Logger.warning`
method, :meth:`!logging.LoggerAdapter.warning` method and
:func:`logging.warning` function.
(Contributed by Victor Stinner in :gh:`105376`.)

* Remove *cafile*, *capath* and *cadefault* parameters of the
Expand Down
12 changes: 1 addition & 11 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'captureWarnings', 'critical', 'debug', 'disable', 'error',
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
'warning', 'getLogRecordFactory', 'setLogRecordFactory',
'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
'getHandlerByName', 'getHandlerNames']

Expand Down Expand Up @@ -1928,11 +1928,6 @@ def warning(self, msg, *args, **kwargs):
"""
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):
"""
Delegate an error call to the underlying logger.
Expand Down Expand Up @@ -2206,11 +2201,6 @@ def warning(msg, *args, **kwargs):
basicConfig()
root.warning(msg, *args, **kwargs)

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

def info(msg, *args, **kwargs):
"""
Log a message with severity 'INFO' on the root logger. If the logger has
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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.
:mod:`logging`: Remove undocumented and untested ``Logger.warn()`` and
``LoggerAdapter.warn()`` methods and ``logging.warn()`` function. Deprecated
since Python 3.3, they were aliases to the :meth:`logging.Logger.warning`
method, :meth:`!logging.LoggerAdapter.warning` method and
:func:`logging.warning` function. Patch by Victor Stinner.