Skip to content

Commit dcc028d

Browse files
authored
gh-105376: Remove logging.warn() and LoggerAdapter.warn() (#106553)
1 parent da98ed0 commit dcc028d

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

Doc/library/logging.rst

+8
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,10 @@ interchangeably.
10151015
Attribute :attr:`manager` and method :meth:`_log` were added, which
10161016
delegate to the underlying logger and allow adapters to be nested.
10171017

1018+
.. versionchanged:: 3.13
1019+
Remove the undocumented ``warn()`` method which was an alias to the
1020+
``warning()`` method.
1021+
10181022

10191023
Thread Safety
10201024
-------------
@@ -1162,6 +1166,10 @@ functions.
11621166
identical to ``warning``. As ``warn`` is deprecated, please do not use
11631167
it - use ``warning`` instead.
11641168

1169+
.. versionchanged:: 3.13
1170+
Remove the undocumented ``warn()`` function which was an alias to the
1171+
:func:`warning` function.
1172+
11651173

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

Doc/whatsnew/3.13.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,11 @@ Removed
348348
use ``locale.setlocale(locale.LC_ALL, "")`` instead.
349349
(Contributed by Victor Stinner in :gh:`104783`.)
350350

351-
* Remove the undocumented and untested ``logging.Logger.warn()`` method,
352-
deprecated since Python 3.3, which was an alias to the
353-
:meth:`logging.Logger.warning` method: use the :meth:`logging.Logger.warning`
354-
method instead.
351+
* :mod:`logging`: Remove undocumented and untested ``Logger.warn()`` and
352+
``LoggerAdapter.warn()`` methods and ``logging.warn()`` function. Deprecated
353+
since Python 3.3, they were aliases to the :meth:`logging.Logger.warning`
354+
method, :meth:`!logging.LoggerAdapter.warning` method and
355+
:func:`logging.warning` function.
355356
(Contributed by Victor Stinner in :gh:`105376`.)
356357

357358
* Remove *cafile*, *capath* and *cadefault* parameters of the

Lib/logging/__init__.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
'captureWarnings', 'critical', 'debug', 'disable', 'error',
3838
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
3939
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
40-
'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
40+
'warning', 'getLogRecordFactory', 'setLogRecordFactory',
4141
'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
4242
'getHandlerByName', 'getHandlerNames']
4343

@@ -1928,11 +1928,6 @@ def warning(self, msg, *args, **kwargs):
19281928
"""
19291929
self.log(WARNING, msg, *args, **kwargs)
19301930

1931-
def warn(self, msg, *args, **kwargs):
1932-
warnings.warn("The 'warn' method is deprecated, "
1933-
"use 'warning' instead", DeprecationWarning, 2)
1934-
self.warning(msg, *args, **kwargs)
1935-
19361931
def error(self, msg, *args, **kwargs):
19371932
"""
19381933
Delegate an error call to the underlying logger.
@@ -2206,11 +2201,6 @@ def warning(msg, *args, **kwargs):
22062201
basicConfig()
22072202
root.warning(msg, *args, **kwargs)
22082203

2209-
def warn(msg, *args, **kwargs):
2210-
warnings.warn("The 'warn' function is deprecated, "
2211-
"use 'warning' instead", DeprecationWarning, 2)
2212-
warning(msg, *args, **kwargs)
2213-
22142204
def info(msg, *args, **kwargs):
22152205
"""
22162206
Log a message with severity 'INFO' on the root logger. If the logger has
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Remove the undocumented and untested ``logging.Logger.warn()`` method,
2-
deprecated since Python 3.3, which was an alias to the
3-
:meth:`logging.Logger.warning` method: use the :meth:`logging.Logger.warning`
4-
method instead. Patch by Victor Stinner.
1+
:mod:`logging`: Remove undocumented and untested ``Logger.warn()`` and
2+
``LoggerAdapter.warn()`` methods and ``logging.warn()`` function. Deprecated
3+
since Python 3.3, they were aliases to the :meth:`logging.Logger.warning`
4+
method, :meth:`!logging.LoggerAdapter.warning` method and
5+
:func:`logging.warning` function. Patch by Victor Stinner.

0 commit comments

Comments
 (0)