[Python-3000] [Python-Dev] warnings.showwarning (was Re: Reminder: last alphas next Wednesday 07-May-2008)
Jean-Paul Calderone
exarkun at divmod.com
Fri May 2 15:47:16 CEST 2008
On Fri, 2 May 2008 09:32:49 -0400, Jean-Paul Calderone <exarkun at divmod.com> wrote:
>On Thu, 1 May 2008 19:31:20 -0700, Brett Cannon <brett at python.org> wrote:
>>
>>[snip]
>>
>>I just closed the release blocker I created (the
>>backwards-compatibility issue with warnings.showwarning() ). I would
>>like to add a PendingDeprecationWarning (or stronger) to 2.6 for
>>showwarning() implementations that don't support the optional 'line'
>>argument. I guess the best way to do it in C code would be to see if
>>PyFunction_GetDefaults() returns a tuple of length two (since
>>showwarning() already has a single optional argument as it is).
>
>Hi Brett,
>
>I'm still seeing some strange behavior from the warnings module, This
>can be observed on the community buildbot for Twisted, for example:
>
>http://python.org/dev/buildbot/community/trunk/x86%20Ubuntu%20Hardy%20trunk/builds/171
>/step-Twisted.zope.stable/0
>
>The log ends with basically all of the warning-related tests in Twisted
>failing, reporting that no warnings happened.
Just to follow up on this part, the failures are due to the tests expecting
to be able to override a different function in the warnings module, not
showwarning (warn_explicit). We used warn_explicit because there's no way
to clear way to disable the filtering that gets applied to showwarning.
warn_explicit doesn't claim to be a public hook, so I guess I won't complain
about this. :)
The below behavior still seems wrong to me, though.
>There is also some strange behavior that can be easily observed in the REPL:
>
> exarkun at boson:~/Projects/python/trunk$ ./python
>/home/exarkun/Projects/Divmod/trunk/Combinator/combinator/xsite.py:7:
>DeprecationWarning: the sets module is deprecated
> from sets import Set
> Python 2.6a2+ (trunk:62636M, May 2 2008, 09:19:41) [GCC 4.1.3
>20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import warnings
> >>> warnings.warn("foo")
> :1: UserWarning: foo # Where'd the module name go?
> >>> def f(*a):
> ... print a
> ...
> >>> warnings.showwarning = f
> >>> warnings.warn("foo")
> >>> # Where'd the warning go?
>
>Any ideas on this?
>
>Jean-Paul
More information about the Python-3000
mailing list