summaryrefslogtreecommitdiff
path: root/Examples/python/exception
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/python/exception')
-rw-r--r--Examples/python/exception/Makefile8
-rw-r--r--Examples/python/exception/example.i9
-rw-r--r--Examples/python/exception/runme.py15
3 files changed, 24 insertions, 8 deletions
diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile
index fb200fbaf..ad3d49fe1 100644
--- a/Examples/python/exception/Makefile
+++ b/Examples/python/exception/Makefile
@@ -6,15 +6,15 @@ INTERFACE = example.i
LIBS = -lm
check: build
- $(MAKE) -f $(TOP)/Makefile python_run
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
build:
- $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
static:
- $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean:
- $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/exception/example.i b/Examples/python/exception/example.i
index 08672c3a8..817c5221c 100644
--- a/Examples/python/exception/example.i
+++ b/Examples/python/exception/example.i
@@ -10,3 +10,12 @@
/* Let's just grab the original header file here */
%include "example.h"
+%inline %{
+// The -builtin SWIG option results in SWIGPYTHON_BUILTIN being defined
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
+
diff --git a/Examples/python/exception/runme.py b/Examples/python/exception/runme.py
index 718707861..9e9241194 100644
--- a/Examples/python/exception/runme.py
+++ b/Examples/python/exception/runme.py
@@ -20,10 +20,17 @@ try:
except RuntimeError,e:
print e.args[0]
-try:
- t.hosed()
-except example.Exc,e:
- print e.code, e.msg
+if not example.is_python_builtin():
+ try:
+ t.hosed()
+ except example.Exc,e:
+ print e.code, e.msg
+else:
+ try:
+ t.hosed()
+ except BaseException,e:
+ # Throwing builtin classes as exceptions not supported (-builtin option)
+ print e
for i in range(1,4):
try: