mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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
5 changed files with 26 additions and 24 deletions
|
@ -37,7 +37,7 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
|
|||
'captureWarnings', 'critical', 'debug', 'disable', 'error',
|
||||
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
|
||||
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
|
||||
'warning', 'getLogRecordFactory', 'setLogRecordFactory',
|
||||
'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
|
||||
'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
|
||||
'getHandlerByName', 'getHandlerNames']
|
||||
|
||||
|
@ -1530,6 +1530,11 @@ class Logger(Filterer):
|
|||
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'.
|
||||
|
@ -1906,6 +1911,11 @@ class LoggerAdapter(object):
|
|||
"""
|
||||
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.
|
||||
|
@ -2169,6 +2179,11 @@ 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue