Commit f0b93467 authored by Stefan Behnel's avatar Stefan Behnel

doc paragraph on properly handling exceptions from C++ constructors

parent 54261947
......@@ -185,17 +185,23 @@ class name from Rectangle.h and adjust for Cython syntax, so now it becomes::
Add public attributes
^^^^^^^^^^^^^^^^^^^^^^
We now need to declare the attributes for use on Cython::
We now need to declare the attributes and methods for use on Cython::
cdef extern from "Rectangle.h" namespace "shapes":
cdef cppclass Rectangle:
Rectangle(int, int, int, int)
Rectangle(int, int, int, int) except +
int x0, y0, x1, y1
int getLength()
int getHeight()
int getArea()
void move(int, int)
Note that the constructor is declared as "except +". If the C++ code or
the initial memory allocation raises an exception due to a failure, this
will let Cython safely raise an appropriate Python exception instead
(see below). Without this declaration, C++ exceptions originating from
the constructor will not be handled by Cython.
Declare a var with the wrapped C++ class
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment