Python 2.6: How to turn off cgitb.py's DeprecationWarning: BaseException.message has been deprecated

Thomas Jollans thomas at jollybox.de
Fri Sep 24 13:25:08 EDT 2010


On Friday 24 September 2010, it occurred to python at bdurham.com to exclaim:
> Python 2.6: We're using the standard lib's cgitb module to
> provide diagnostic messages when unexpected exceptions occur.
> 
> Unfortunately, this module raises a DeprecationWarning like below
> when it is used:
> 
> C:\Python26\lib\cgitb.py:245: DeprecationWarning:
> BaseException.message has been
>  deprecated as of Python 2.6
>   value = pydoc.text.repr(getattr(evalue, name))
> 
> Is there some way to disable this specific warning message (our
> customers find it disconcerting) or do we have to go in and edit
> the cgitb.py module itself? Also, wondering if this warning has
> been addressed in Python 2.7/3.x?

Yes. Filtering is an important part of the Python warnings framework:

http://docs.python.org/library/warnings.html#warnings.filterwarnings
http://www.python.org/dev/peps/pep-0230/



More information about the Python-list mailing list