]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105376: Remove logging.warn() and LoggerAdapter.warn() (#106553)
authorVictor Stinner <vstinner@python.org>
Sun, 9 Jul 2023 08:32:50 +0000 (10:32 +0200)
committerGitHub <noreply@github.com>
Sun, 9 Jul 2023 08:32:50 +0000 (10:32 +0200)
Doc/library/logging.rst
Doc/whatsnew/3.13.rst
Lib/logging/__init__.py
Misc/NEWS.d/next/Library/2023-06-06-15-32-44.gh-issue-105376.W4oDQp.rst

index d7a389fa13d6a0c3ba97d28e5cb471597e08871c..4e07eabd57f5e9924f6526de7dac21220573bc09 100644 (file)
@@ -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
 -------------
@@ -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)
 
index b376f846b725e1facf034aa0e00d99ae96139767..7a4ec5fd913033872ecabf9dead0bf8cc13c284a 100644 (file)
@@ -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
index fe2039af0334a0f9696e5b42f6e2c2760f46e449..2a011b6d2ff15ddb20b4a775bf10a18fdf0e2a95 100644 (file)
@@ -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',
-           'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
+           'warning', 'getLogRecordFactory', 'setLogRecordFactory',
            'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
            'getHandlerByName', 'getHandlerNames']
 
@@ -1928,11 +1928,6 @@ 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.
@@ -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
index a7d3172ca4c642fbc30ee8ce1a48e7563b335734..2ed6b5e0a7ac0adf7dd91316eae217f7544b9908 100644 (file)
@@ -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.