[IronPython] warnings module

Sanghyeon Seo sanxiyn at gmail.com
Thu Dec 29 10:43:47 CET 2005

I looked at RegressionTests wiki page and saw several mentions of
warnings module not working. As I know this problem from working on
PyPy, I want to inform you.

The problem is this:

$ python
Python 2.4.2 (#2, Nov 20 2005, 17:04:48)
[GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> isinstance(Exception, types.ClassType)

$ py.py
PyPy 0.8.0 in StdObjSpace on top of Python 2.4.2 (startuptime: 3.20 secs)
>>>> import types
>>>> isinstance(Exception, types.ClassType)

Now, warnings.py does rather harmful sanity check, checking whether
warnings to be filtered is instance of old-style class. There is no
justification for this, and I think it's up to implementors to decide
whether exceptions are old-style or new-style. PyPy's patched
warnings.py is available from

The only difference is commenting out of two lines where
types.ClassType check appears.

With patched warnings.py, IronPython passes test_warnings, and
warnings module seems to work in general.

Hope this help,
Seo Sanghyeon

More information about the Ironpython-users mailing list