changeset: 73039:37479f0f68bc user: Vinay Sajip date: Fri Oct 21 07:33:42 2011 +0100 files: Doc/library/logging.rst Lib/logging/__init__.py Misc/NEWS description: Closes #13235: Added deprecation for warn() methods and function in logging. diff -r c1effa2cdd20 -r 37479f0f68bc Doc/library/logging.rst --- a/Doc/library/logging.rst Thu Oct 20 23:54:17 2011 +0200 +++ b/Doc/library/logging.rst Fri Oct 21 07:33:42 2011 +0100 @@ -189,6 +189,9 @@ 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) @@ -880,8 +883,12 @@ .. 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) diff -r c1effa2cdd20 -r 37479f0f68bc Lib/logging/__init__.py --- a/Lib/logging/__init__.py Thu Oct 20 23:54:17 2011 +0200 +++ b/Lib/logging/__init__.py Fri Oct 21 07:33:42 2011 +0100 @@ -1243,7 +1243,10 @@ 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): """ @@ -1556,7 +1559,10 @@ """ 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): """ @@ -1766,7 +1772,10 @@ 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): """ diff -r c1effa2cdd20 -r 37479f0f68bc Misc/NEWS --- a/Misc/NEWS Thu Oct 20 23:54:17 2011 +0200 +++ b/Misc/NEWS Fri Oct 21 07:33:42 2011 +0100 @@ -326,6 +326,8 @@ 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