[Python-Dev] Re: [Python-checkins] python/dist/src/Lib warnings.py,1.19,1.20
Guido van Rossum
guido@python.org
Wed, 14 May 2003 14:23:16 -0400
> Skip> I'll see what I can come up with and submit a patch.
>
> Okay, this seems too simple. ;-) There's no need to compile the message and
> module arguments to filterwarnings. Just store them as strings and call
> re.match() later with the appropriate args. That takes care of that one. I
> think use of the -W command line flag is infrequent enough that it doesn't
> really matter that _processoptions, _setoption and -getcategory might get
> called at startup. Most of the time sys.warnoptions will be an empty list,
> so _setoption and _getcategory won't be called.
OK. Please report old and new startup times!
> Aside: Why are message and module names given on the command line treated as
> literal strings while message and module names which are passed directly to
> filterwarnings() treated as regular expressions? If they were treated as
> regular expressions, the calls to re.escape() could be removed and
> _setoptions wouldn't use re either.
Um, I don't remember. It would seem to be useful, wouldn't it? The
only reason I can come up with is that for dotted names, the dot would
have to be escaped on the command line, and escaping something on the
command line is painful because \ is also a shell escape character, so
you'd have to escape the escape.
--Guido van Rossum (home page: http://www.python.org/~guido/)