Stefan Behnel, 29.06.2012 07:45:
> [moving this to cython-devel as it's getting technical]
> 
> Robert Bradshaw, 28.06.2012 21:46:
>> On Thu, Jun 28, 2012 at 11:38 AM, Stefan Behnel wrote:
>>> currently, when I write "new CppClass()" in Cython, it generates a straight
>>> call to the "new" operator. It doesn't do any error handling. And the
>>> current documentation doesn't even mention this case.
>>>
>>> Is there a "standard" way to handle this? It seems that C++ has different
>>> ways to deal with failures here but raises an exception by default. Would
>>> you declare the constructor(s) with an "except +MemoryError"? Is there a
>>> reason Cython shouldn't be doing this automatically (if nothing else was
>>> declared) ?
>>
>> I think it certainly makes sense to declare the default constructor as
>> "except +" (and std::bad_alloc should become MemoryError),
> 
> Right. The code in the constructor can raise other exceptions that must
> also be handled properly. An explicit "except +" will handle that.

What about the declarations that we ship in libcpp.*? They currently lack
any such exception declarations. Can we safely add them where appropriate?

And, would someone care to do it?

Stefan
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to