Re: Python 2.7 disables deprecation warnings by default

Tres Seaver <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jim Fulton wrote:
> I'm guessing that this has already been noticed and discussed, but
> Python 2.7 disables deprecation warnings by default.
> 
> This will cause many tests to fail that checked that deprecation were
> issued.
> 
> This change seems likely to make Python's deprecation system useless
> and thus unused.
> 
> I noticed this yesterday when testing a project with Python 2.7 that
> had some deprecation tests. I modified the test runner script to call:
> 
>    warnings.simplefilter('default')
> 
> to renable deprecation warnings.  This allowed my tests to pass and
> also, ironically, showed new useful deprecation warnings in asyncore.
> 
> I'm not sure what the best way to handle this is.  My initial thought
> is that all test runners should enable deprecations by default.  This
> seems hard to enforce.
> 
> Individual test modules can do this, but I'm uncomfortable having a
> test script make a global setting like this and the warning module
> doesn't seem to provide a way to capture the current state so it can
> be reset after running tests.

As of Python 2.6, the warnings module sports a context manager::

  with warnings.catch_warnings():
    warnings.simplefilter("default")
    fxn()


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkw0iDUACgkQ+gerLs4ltQ4C7gCfd8WbirfwtAxnc99yhjfdPlvK
4SYAoNxDTkSp1TAdOe2Go3sBJtM0b1/t
=3cc2
-----END PGP SIGNATURE-----

_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.