mirror of https://github.com/python/cpython
gh-105376: Restore deprecated logging warn() method (#122775)
This reverts commitdcc028d924
and commit6c54e5d721
. Keep the deprecated logging warn() method in Python 3.13. Co-authored-by: Gregory P. Smith <greg@krypto.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
b4a316087c
commit
d3239976a8
|
@ -67,6 +67,9 @@ although there is currently no date scheduled for their removal.
|
||||||
* ``EntryPoints`` tuple interface.
|
* ``EntryPoints`` tuple interface.
|
||||||
* Implicit ``None`` on return values.
|
* Implicit ``None`` on return values.
|
||||||
|
|
||||||
|
* :mod:`logging`: the ``warn()`` method has been deprecated
|
||||||
|
since Python 3.3, use :meth:`~logging.warning()` instead.
|
||||||
|
|
||||||
* :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
|
* :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
|
||||||
BytesIO and binary mode instead.
|
BytesIO and binary mode instead.
|
||||||
|
|
||||||
|
|
|
@ -352,10 +352,6 @@ in a module, ``__name__`` is the module's name in the Python package namespace.
|
||||||
.. versionchanged:: 3.8
|
.. versionchanged:: 3.8
|
||||||
The *stacklevel* parameter was added.
|
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)
|
.. method:: Logger.info(msg, *args, **kwargs)
|
||||||
|
|
||||||
|
@ -368,6 +364,10 @@ in a module, ``__name__`` is the module's name in the Python package namespace.
|
||||||
Logs a message with level :const:`WARNING` on this logger. The arguments are
|
Logs a message with level :const:`WARNING` on this logger. The arguments are
|
||||||
interpreted as for :meth:`debug`.
|
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)
|
.. method:: Logger.error(msg, *args, **kwargs)
|
||||||
|
|
||||||
Logs a message with level :const:`ERROR` on this logger. The arguments are
|
Logs a message with level :const:`ERROR` on this logger. The arguments are
|
||||||
|
@ -1124,11 +1124,6 @@ information into logging calls. For a usage example, see the section on
|
||||||
Attribute :attr:`!manager` and method :meth:`!_log` were added, which
|
Attribute :attr:`!manager` and method :meth:`!_log` were added, which
|
||||||
delegate to the underlying logger and allow adapters to be nested.
|
delegate to the underlying logger and allow adapters to be nested.
|
||||||
|
|
||||||
.. versionchanged:: 3.13
|
|
||||||
|
|
||||||
Remove the undocumented :meth:`!warn`` method which was an alias to the
|
|
||||||
:meth:`!warning` method.
|
|
||||||
|
|
||||||
.. versionchanged:: 3.13
|
.. versionchanged:: 3.13
|
||||||
|
|
||||||
The *merge_extra* argument was added.
|
The *merge_extra* argument was added.
|
||||||
|
@ -1224,10 +1219,6 @@ functions.
|
||||||
identical to ``warning``. As ``warn`` is deprecated, please do not use
|
identical to ``warning``. As ``warn`` is deprecated, please do not use
|
||||||
it - use ``warning`` instead.
|
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)
|
.. function:: error(msg, *args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -1397,16 +1397,6 @@ locale
|
||||||
use ``locale.setlocale(locale.LC_ALL, "")`` instead.
|
use ``locale.setlocale(locale.LC_ALL, "")`` instead.
|
||||||
(Contributed by Victor Stinner in :gh:`104783`.)
|
(Contributed by Victor Stinner in :gh:`104783`.)
|
||||||
|
|
||||||
logging
|
|
||||||
-------
|
|
||||||
|
|
||||||
* :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`.)
|
|
||||||
|
|
||||||
pathlib
|
pathlib
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
|
||||||
'captureWarnings', 'critical', 'debug', 'disable', 'error',
|
'captureWarnings', 'critical', 'debug', 'disable', 'error',
|
||||||
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
|
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
|
||||||
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
|
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
|
||||||
'warning', 'getLogRecordFactory', 'setLogRecordFactory',
|
'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
|
||||||
'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
|
'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
|
||||||
'getHandlerByName', 'getHandlerNames']
|
'getHandlerByName', 'getHandlerNames']
|
||||||
|
|
||||||
|
@ -1530,6 +1530,11 @@ class Logger(Filterer):
|
||||||
if self.isEnabledFor(WARNING):
|
if self.isEnabledFor(WARNING):
|
||||||
self._log(WARNING, 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):
|
def error(self, msg, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Log 'msg % args' with severity 'ERROR'.
|
Log 'msg % args' with severity 'ERROR'.
|
||||||
|
@ -1906,6 +1911,11 @@ class LoggerAdapter(object):
|
||||||
"""
|
"""
|
||||||
self.log(WARNING, 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):
|
def error(self, msg, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Delegate an error call to the underlying logger.
|
Delegate an error call to the underlying logger.
|
||||||
|
@ -2169,6 +2179,11 @@ def warning(msg, *args, **kwargs):
|
||||||
basicConfig()
|
basicConfig()
|
||||||
root.warning(msg, *args, **kwargs)
|
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):
|
def info(msg, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Log a message with severity 'INFO' on the root logger. If the logger has
|
Log a message with severity 'INFO' on the root logger. If the logger has
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Restore the deprecated :mod:`logging` ``warn()`` method. It was removed in
|
||||||
|
Python 3.13 alpha 1. Keep the deprecated ``warn()`` method in Python 3.13.
|
||||||
|
Patch by Victor Stinner.
|
Loading…
Reference in New Issue