[C++-sig] Re: A feature request, and, Re: Re: Exception translation to python classes

David Abrahams dave at boost-consulting.com
Wed Sep 24 00:39:37 CEST 2003


"Niall Douglas" <s_sourceforge at nedprod.com> writes:

> On 23 Sep 2003 at 9:17, Lijun Qin wrote:
>
>> form of code, you need to use the PyErr_NewException() API to create a
>> new exception class derived from PyExc_Exception class. And to create
>> '__init__' and '__str__' function, you also need to create two method
>> object for two callable object. I have managed to make it work, but it
>> need a lot of handcraft.
>
> Thanks for telling me this, you've just saved me a day of work. Dave, 
> what do you think?

I'm not quite sure what you're asking my opinion about.

I think the base class capability described below is a really good
idea.  Lijun posted some code which does this IIRC, but I can't find
it.  It also sounds like you're asking me about something else.

If someone can come up with code, docs, and tests, I'd like to put it
in the library.  I don't think I have time to do it myself at the
moment.

>> I this process, I have found that if boost.python can support
>> specifing an existing Python class as base class (or one of the
>> basses), such as specify 'PyExc_Excetion' as the base class of the
>> generated python class, it'll be a much simpler life for us.
>
> I agree. But it's not crucial for what I need, so I'll have my 
> exception class generate a textual description and report that to 
> python (ie; I'm going to cheat :) )


-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list