[Python-checkins] r62787 - python/trunk/Lib/warnings.py
Brett Cannon
brett at python.org
Wed May 7 20:40:13 CEST 2008
On Tue, May 6, 2008 at 3:31 PM, benjamin.peterson
<python-checkins at python.org> wrote:
> Author: benjamin.peterson
> Date: Wed May 7 00:31:52 2008
> New Revision: 62787
>
> Log:
> Make the Python implementation of warnings compatible with the C implementation regarding non-callable showwarning
>
>
> Modified:
> python/trunk/Lib/warnings.py
>
> Modified: python/trunk/Lib/warnings.py
> ==============================================================================
> --- python/trunk/Lib/warnings.py (original)
> +++ python/trunk/Lib/warnings.py Wed May 7 00:31:52 2008
> @@ -278,6 +278,9 @@
> _show_warning(message, category, filename, lineno)
> else:
> warn(showwarning_msg, DeprecationWarning)
> + if not callable(showwarning):
> + raise TypeError("warnings.showwarning() must be set to a "
> + "function or method")
> # Print message and context
> showwarning(message, category, filename, lineno)
I purposefully didn't put this check in the Python code as the proper
exception will propagate and callable is not in 3.x for a reason; it
is not exactly a reliable check.
-Brett
More information about the Python-checkins
mailing list