[Python-Dev] Warning Framework (PEP 230)
Thomas Wouters
thomas@xs4all.net
Mon, 11 Dec 2000 17:58:39 +0100
On Mon, Dec 11, 2000 at 11:02:29AM -0500, Barry A. Warsaw wrote:
> - A function in the warn module is better than one in the sys module.
> "from warnings import warn" is good enough to not warrant a
> built-in. I get the sense that the PEP description is behind
> Guido's currently implementation here.
+1 on this. I have a response to Guido's first posted PEP on my laptop, but
due to a weekend in Germany wasn't able to post it before he updated the
PEP. I guess I can delete the arguments for this, now ;) but lets just say I
think 'sys' is being a bit overused, and the case of a function in sys and
its data in another module is just plain silly.
> - When PyErr_Warn() returns 1, does that mean a warning has been
> transmuted into an exception, or some other exception occurred
> during the setting of the warning? (I think I know, but the PEP
> could be clearer here).
How about returning 1 for 'warning turned into exception' and -1 for 'normal
exception' ? It would be slightly more similar to other functions if '-1'
meant 'exception', and it would be easy to put in an if statement -- and
still allow C code to ignore the produced error, if it wanted to.
> - It would be nice if lineno can be a range specification. Other
> matches are based on regexps -- think of this as a line number
> regexp.
+0 on this... I'm not sure if such fine-grained control is really necessary.
I liked the hint at 'per function' granularity, but I realise it's tricky to
do right, what with naming issues and all that.
> - Regexp matching on messages should be case insensitive.
How about being able to pass in compiled regexp objects as well as strings ?
I haven't looked at the implementation at all, so I'm not sure how expensive
it would be, but it might also be nice to have users (= programmers) pass in
an object with its own 'match' method, so you can 'interactively' decide
whether or not to raise an exception, popup a window, and what not. Sort of
like letting 'action' be a callable, which I think is a good idea as well.
--
Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!