[Python-Dev] Warning Framework (PEP 230)

Barry A. Warsaw barry@digicool.com
Mon, 11 Dec 2000 11:02:29 -0500


Some of my thoughts after reading the PEP and Paul/Guido's exchange.

- 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.

- 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).

- 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.

- Why not do setupwarnings() in site.py?

- Regexp matching on messages should be case insensitive.

- The second argument to sys.warn() or PyErr_Warn() can be any class,
  right?  If so, it's easy for me to have my own warning classes.
  What if I want to set up my own warnings filters?  Maybe if `action'
  could be a callable as well as a string.  Then in my IDE, I could
  set that to "mygui.popupWarningsDialog".

-Barry