3 May 2009 hypatia   » (Journeyer)

Suppressing Python 2.6 DeprecationWarning

Since Python 3.0+ is backwards incompatible (or, if you like, a new Python-esque language), Python 2.6 is enormously grouchy about announcing that everything under the sun has been deprecated. For example:

$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import md5
__main__:1: DeprecationWarning: the md5 module is deprecated; use hashlib instead
>>> 

While this is very helpful for one's own code, my email is now filling with warnings about how Twisted, Venus and several other libraries have deprecated elements (import md5 being a particularly common offender). There's nothing I can do about that, and being warned hourly about some of them is therefore unhelpful. Here's how you turn it off: call python with -Wignore::DeprecationWarning.

$ python -Wignore::DeprecationWarning
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import md5
>>> 

As you can probably guess, by doing this you run the risk of your code failing to work with some future version of Python and you not getting much warning about it. But your inbox or error logs may thank you.

Syndicated 2009-05-03 10:20:32 (Updated 2009-05-04 00:08:32) from puzzling dot org: thoughts

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!