It appears that the -W option on starting python doesn't work the same as the warnings module. In particular, the "message" parameter is not treated as a regular expression, but rather a string literal which must appear at the beginning of a warning message in order to match. The treatment of -W in "python -h" makes no mention of the warnings module (and I actually couldn't find any definitive documentation on command line switches), though the documentation for the warnings module does say:
The interpreter saves the arguments for all -W options without interpretation in sys.warnoptions; the warnings module parses these when it is first imported That also kind of maybe implies that warnings is automatically imported by the interpreter, but it doesn't actually say so. How should this be treated? ========= Here's an example of the problem. (I've reproduced it in version 2.5 also) $ python -W ignore:whenThreaded Python 2.4.2 (#2, Mar 10 2006, 15:10:56) [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5 Type "help", "copyright", "credits" or "license" for more information. >>> from twisted.internet import reactor /usr/local/lib/python2.4/site-packages/twisted/internet/base.py:245: DeprecationWarning: threadable.whenThreaded is deprecated. Use application-level logic instead. threadable.whenThreaded(self.initThreads) >>> $ python -W ignore:'threadable.whenThreaded is deprecated. Use application-level logic instead.' Python 2.4.2 (#2, Mar 10 2006, 15:10:56) [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5 Type "help", "copyright", "credits" or "license" for more information. >>> from twisted.internet import reactor >>> $ python -W ignore:threadable.whenThreaded Python 2.4.2 (#2, Mar 10 2006, 15:10:56) [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5 Type "help", "copyright", "credits" or "license" for more information. >>> from twisted.internet import reactor >>> -- http://mail.python.org/mailman/listinfo/python-list