[Zope-dev] Show Deprecation Warnings in Zope2
Tres Seaver
tseaver at palladion.com
Mon Feb 16 16:41:22 CET 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 02/16/2015 07:09 AM, Jens W. Klein wrote:
> In past in Zope2 it was possible to turn DeprecationWarnings on and
> off in zope.conf by adding a snippet like:
>
> <warnfilter> action always category exceptions.DeprecationWarning
> </warnfilter>
>
> I wondered by this is no longer possible. So I found the code
> responsible for adding the filter here:
>
> https://github.com/zopefoundation/Zope/blob/master/src/Zope2/Startup/warnfilter.py#L53
>
> It adds a custom filter at the _end_ of the filters list (last digit
> = 1). See also
> https://docs.python.org/2/library/warnings.html#warnings.filterwarnings
>
> Now since Python 2.7 some defaults changed. One is, that
> DeprecationWarnings are ignored by default. So the first rule in the
> default Python 2.7 filters is to ignore DeprecationWarnings.
>
> see also https://docs.python.org/2/using/cmdline.html#cmdoption-W
>
> and we can check this in code (naked python)
>
>>>> import warnings warnings.filters
> [('ignore', None, <type 'exceptions.DeprecationWarning'>, None, 0),
> ('ignore', None, <type 'exceptions.PendingDeprecationWarning'>, None,
> 0), ('ignore', None, <type 'exceptions.ImportWarning'>, None, 0),
> ('ignore', None, <type 'exceptions.BytesWarning'>, None, 0)]
>
> So with the zope.conf setting there is no possibility to override the
> defaults: The list is processed from the head to tail and first match
> wins.
>
> Is there any good reason to append the zope custom filter to the list?
> If it would be prepended (which is also the default settings for
> warnings.filterwarnings) all works as expected.
>
> I can provide this tiny patch + pull request if the change is fine.
SGTM.
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQIcBAEBAgAGBQJU4g+iAAoJEPKpaDSJE9HYiocQAL2kGJNNSbX7cJSXNAQIdvxJ
pLwguk3L/o6VP4cPf3SxLQZuz74+xiGnHDqPWr5Hki6xeY7CkJejQizpiZQcyx5Z
iNfuDwlhRIJ0ExqigZIpmUEsINk1iiAjsTadWzoxLcFjlGCqHj20edA1+2gHmnjK
HHxQ5FRMrTrRmtB2pv4/wWiZ1tvVQ8pLKLh0woDTSngs4ll1/ILhL9GDpACOP0jO
EaMtlZ9X99gPzC2855ZzUz/48snZo1r5W1AJXGTmqqQ7ykfBGlq1MN1J9Y+hghDP
+pM2GkMYFMIOkXWoVsMpoTNJIcpUfNaIZQ3rhxWELHTnRU5Il281mC+cFTZHnLQT
8QjK7PS0GM+7F7dN9nvindqzDZb5Nz7RC49RRMtS5/whGvkZw6yXfrv+ooEomCLA
x7A0eIEGSmJEbu0Y/GrWln0bGOvqGDgIiSBMmuywuXibUMXx1IRHFBnMk6lygNE1
svrCmdwfkXNO0Otf3/l/djMS5JKw1fqNsH9dAAVi1470s9T89kzV3mzCObadl0hI
8sBnLKyjHlwiHFV5lSK7FWrjGo8H01tjSFxDaYm62onAO518cTlHpb4OK9YHVgxx
IheqqitHJZCCEweE+RoWfLRi14jqhabMMt7IpqUwLZJ1OG221BoQ6mUk2QR6fTxy
ARSR+8VNN9jNgIPdEcUh
=W3N9
-----END PGP SIGNATURE-----
More information about the Zope-Dev
mailing list