diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index e766baaf0..0c88185cb 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2350,14 +2350,71 @@ please refer to the python documentation:
Use of the -builtin option implies a couple of limitations:
Some legacy syntax is no longer supported; in particular:
Wrapped types may not be thrown as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:
+ +
+typedef struct {
+ PyObject_HEAD
+ PyObject *dict;
+ PyObject *args;
+ PyObject *message;
+} PyBaseExceptionObject;
+
+But swig-generated wrappers expect that all swig-wrapped classes will have this struct layout:
+ +
+typedef struct {
+ PyObject_HEAD
+ void *ptr;
+ swig_type_info *ty;
+ int own;
+ PyObject *next;
+ PyObject *dict;
+} SwigPyObject;
+
+There are workarounds for this. For example, if you wrap this class: + +
+class MyException {
+public:
+ MyException (const char *msg_);
+ ~MyException ();
+
+ const char *what () const;
+
+private:
+ char *msg;
+};
+
+... you can define this python class, which may be raised as an exception:
+ ++class MyPyException (Exception, MyException) : + def __init__(self, msg, *args) : + Exception.__init__(self, *args) + self.myexc = MyException(msg) + def what (self) : + return self.myexc.what() ++
Reverse binary operators (e.g., __radd__) are not supported.