[Python.NET] Small improvment for CLR exceptions

Roman Yakovenko roman.yakovenko at gmail.com
Sun May 29 05:02:18 CEST 2005


Sorry for being unclear. My main usage of Python.Net is writing
unittest for client \ server application. ( I have more then 330
unitests :-) ). CLR.Exception don't play nice with python
unittest framework. If test fails with exception unitest framework
will print error message for regular python exception. In case of
CLR.Exception it can't print message of exception.

Roman

On 5/27/05, Brian Lloyd <brian at zope.com> wrote:
> > 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
> string:
> 
> >>> 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