[Python.NET] Small improvment for CLR exceptions

Brian Lloyd brian at zope.com
Fri May 27 19:42:19 CEST 2005

> Sorry this was posted in wring thread.
> On 5/25/05, Roman Yakovenko <roman.yakovenko at gmail.com> wrote:
> > Hi. Bryan could you add __str__ function to all CLR exceptions ?
> > It will improve usability of this exception with python 
> unittest package.
> > 
> > Thanks

I guess I'm unclear on the goal. Looking at the built-in Python 
exceptions, they have a __repr__, but __str__ returns an empty 

>>> e = IndexError()
>>> repr(e)
'<exceptions.IndexError instance at 0x07016AF8>'
>>> str(e)

CLR exceptions currently have the same behavior:

>>> e = CLR.System.NullReferenceException()
>>> repr(e)
'<CLR.System.NullReferenceException object at 0x070158B0>'
>>> str(e)

I'm happy to add things to make life easier for folks -- I just 
don't understand what you're asking for yet :) What would you 
want/expect to get from str(e) on a CLR exception?

Brian Lloyd        brian at zope.com
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com 

More information about the PythonDotNet mailing list