Bypass Python exmples not supported by -builtin

Builtin classes as exceptions not supported, so don't run these aspects
of the examples when using -builtin.
This commit is contained in:
William S Fulton 2014-10-07 20:13:32 +01:00
commit 808d4b4798
4 changed files with 34 additions and 6 deletions

View file

@ -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
%}

View file

@ -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: