]> Creatis software - gdcm.git/blob - Testing/ExceptionAndPython/README
Fix mistypings
[gdcm.git] / Testing / ExceptionAndPython / README
1 READ THIS FIRST:
2 the oddities described below are NOT present when using
3 wxPythonGTK-py2.2-2.4.0.2-2 but are present when wxPythonGTK-py2.2-2.3.4.2-1.
4 -------------------------------------------------------------------------
5 The purpous of this set of files is to illustrate an unexpected behavior
6 of exception handling of swig wrapped c++ libraries with wxPython.
7 Context:
8  - g++ version 2.96 or 3.2
9  - swig version 1.3.16u
10  - python2.2
11
12 Consider the code in one of the foo_main.cxx say foo_main.cxx.minimal:
13         #include <iostream>
14         
15         void MyWrappedFunction(void) {
16            try { throw "In thrower"; }
17            catch (const char * str) { cout<<"Exception"<< str << endl; }
18         }
19         
20         int main() {
21                 MyWrappedFunction();
22                 return 0;
23         }
24 When compiling this code and executing it one obtains the correct behavior
25 of the exception i.e. ExceptionIn thrower.
26 Now, wrap the above code with swig and invoque the following python
27 script (see test.py):
28   import wxPython.wx
29   import foo
30   foo.MyWrappedFunction()
31 Surprisingly enough the exception won't be caugth, but terminate will
32 catch it and invoke abort.
33 Note that the exception is properly caught when one doesn't import 
34 wxPython.
35 Note that the exception is properly caught when one doesn't import 
36 wxPython.
37
38 In order to play with this example, try the following:
39 ln -s foo_main.cxx.minimal foo_main.cxx 
40 ln -s foo.cxx.minimal foo.cxx 
41 make
42 ./main
43 ExceptionIn thrower
44 python test.py
45