swig/swig — pull request #3 by ptomulik (2013-01-04 16:25:29+00:00)
Title: SFbug1295

Fix proposition for Source Forge BUG #1295. Includes python test case.

## Test results

### unpatched:

```bash
ptomulik@node00:~$ cd ~/projects/swig/Examples/test-suite/python/
ptomulik@node00:~/projects/swig/Examples/test-suite/python$ make li_std_except_as_class.cpptest
if [ -f ./li_std_except_as_class_runme.py ]; then echo "checking testcase li_std_except_as_class (with run test) under python" ; else echo "checking testcase li_std_except_as_class under python" ; fi;
checking testcase li_std_except_as_class (with run test) under python
make -f ../../../Examples/Makefile CXXSRCS="" SWIG_LIB="../../../Lib" SWIG=" ../../../preinst-swig" INCLUDES="-I../../../Examples/test-suite" SWIGOPT="-outcurrentdir -I../../../Examples/test-suite" NOLINK=true TARGET="li_std_except_as_class" INTERFACEDIR="../../../Examples/test-suite/" INTERFACE="li_std_except_as_class.i" python_cpp
make[1]: Entering directory `/home/ptomulik/projects/swig/Examples/test-suite/python'
../../../preinst-swig -python -c++ -outcurrentdir -I../../../Examples/test-suite ../../../Examples/test-suite/li_std_except_as_class.i
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:41: Warning 302: Identifier 'exception' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:13: Warning 302: previous definition of 'exception'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:47: Warning 302: Identifier 'bad_exception' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:19: Warning 302: previous definition of 'bad_exception'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:51: Warning 302: Identifier 'logic_error' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:23: Warning 302: previous definition of 'logic_error'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:56: Warning 302: Identifier 'domain_error' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:28: Warning 302: previous definition of 'domain_error'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:61: Warning 302: Identifier 'invalid_argument' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:33: Warning 302: previous definition of 'invalid_argument'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:66: Warning 302: Identifier 'length_error' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:38: Warning 302: previous definition of 'length_error'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:71: Warning 302: Identifier 'out_of_range' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:43: Warning 302: previous definition of 'out_of_range'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:76: Warning 302: Identifier 'runtime_error' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:48: Warning 302: previous definition of 'runtime_error'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:81: Warning 302: Identifier 'range_error' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:53: Warning 302: previous definition of 'range_error'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:86: Warning 302: Identifier 'overflow_error' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:58: Warning 302: previous definition of 'overflow_error'.
/home/ptomulik/projects/swig/Lib/typemaps/std_except.swg:91: Warning 302: Identifier 'underflow_error' redefined (ignored),
/home/ptomulik/projects/swig/Lib/std/std_except.i:63: Warning 302: previous definition of 'underflow_error'.
g++ -c -fpic li_std_except_as_class_wrap.cxx -I../../../Examples/test-suite -I/usr/include/python2.7 -I/usr/lib/python2.7/config
g++ -shared li_std_except_as_class_wrap.o -o _li_std_except_as_class.so
make[1]: Leaving directory `/home/ptomulik/projects/swig/Examples/test-suite/python'
if [ -f ./li_std_except_as_class_runme.py ]; then env LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH PYTHONPATH=.:.:$PYTHONPATH python ./li_std_except_as_class_runme.py; fi
Traceback (most recent call last):
File "./li_std_except_as_class_runme.py", line 7, in
except logic_error: pass
SystemError: 'finally' pops bad exception
make: *** [li_std_except_as_class.cpptest] Error 1
```
### patched:

```bash
ptomulik@node00:~$ cd ~/projects/swig/Examples/test-suite/python/
ptomulik@node00:~/projects/swig/Examples/test-suite/python$ make li_std_except_as_class.cpptest
if [ -f ./li_std_except_as_class_runme.py ]; then echo "checking testcase li_std_except_as_class (with run test) under python" ; else echo "checking testcase li_std_except_as_class under python" ; fi;
checking testcase li_std_except_as_class (with run test) under python
make -f ../../../Examples/Makefile CXXSRCS="" SWIG_LIB="../../../Lib" SWIG=" ../../../preinst-swig" INCLUDES="-I../../../Examples/test-suite" SWIGOPT="-outcurrentdir -I../../../Examples/test-suite" NOLINK=true TARGET="li_std_except_as_class" INTERFACEDIR="../../../Examples/test-suite/" INTERFACE="li_std_except_as_class.i" python_cpp
make[1]: Entering directory `/home/ptomulik/projects/swig/Examples/test-suite/python'
../../../preinst-swig -python -c++ -outcurrentdir -I../../../Examples/test-suite ../../../Examples/test-suite/li_std_except_as_class.i
g++ -c -fpic li_std_except_as_class_wrap.cxx -I../../../Examples/test-suite -I/usr/include/python2.7 -I/usr/lib/python2.7/config
g++ -shared li_std_except_as_class_wrap.o -o _li_std_except_as_class.so
make[1]: Leaving directory `/home/ptomulik/projects/swig/Examples/test-suite/python'
if [ -f ./li_std_except_as_class_runme.py ]; then env LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH PYTHONPATH=.:.:$PYTHONPATH python ./li_std_except_as_class_runme.py; fi
```