Skip to content

Commit

Permalink
Closes #13235: Added deprecation for warn() methods and function in l…
Browse files Browse the repository at this point in the history
…ogging.
  • Loading branch information
vsajip committed Oct 21, 2011
1 parent ac65d96 commit 04d5bc0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
11 changes: 9 additions & 2 deletions Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ instantiated directly, but always through the module-level function
Logs a message with level :const:`WARNING` on this logger. The arguments are
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)

Expand Down Expand Up @@ -880,8 +883,12 @@ functions.

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

Logs a message with level :const:`WARNING` on the root logger. The arguments are
interpreted as for :func:`debug`.
Logs a message with level :const:`WARNING` on the root logger. The arguments
are interpreted as for :func:`debug`.

.. note:: There is an obsolete function `warn()` which is functionally
identical to `warning()`. As `warn()` is deprecated, please do not use
it - use `warning()` instead.


.. function:: error(msg, *args, **kwargs)
Expand Down
15 changes: 12 additions & 3 deletions Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,10 @@ def warning(self, msg, *args, **kwargs):
if self.isEnabledFor(WARNING):
self._log(WARNING, msg, args, **kwargs)

warn = warning
def warn(self, msg, *args, **kwargs):
warnings.warn("The 'warn' method is deprecated, "
"use 'warning' instead", PendingDeprecationWarning, 2)
self.warning(msg, *args, **kwargs)

def error(self, msg, *args, **kwargs):
"""
Expand Down Expand Up @@ -1556,7 +1559,10 @@ def warning(self, msg, *args, **kwargs):
"""
self.log(WARNING, msg, *args, **kwargs)

warn = warning
def warn(self, msg, *args, **kwargs):
warnings.warn("The 'warn' method is deprecated, "
"use 'warning' instead", PendingDeprecationWarning, 2)
self.warning(msg, *args, **kwargs)

def error(self, msg, *args, **kwargs):
"""
Expand Down Expand Up @@ -1766,7 +1772,10 @@ def warning(msg, *args, **kwargs):
basicConfig()
root.warning(msg, *args, **kwargs)

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

def info(msg, *args, **kwargs):
"""
Expand Down
2 changes: 2 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ Core and Builtins
Library
-------

- Issue #13235: Added PendingDeprecationWarning to warn() method and function.

- Issue #9168: now smtpd is able to bind privileged port.

- Issue #12529: fix cgi.parse_header issue on strings with double-quotes and
Expand Down

0 comments on commit 04d5bc0

Please sign in to comment.