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:

View file

@ -109,6 +109,12 @@
%template(doubleQueue) Queue<double>;
%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

@ -1,10 +1,16 @@
# file: runme.py
import example
if example.is_python_builtin():
print "Skipping example: -builtin option does not support %exceptionclass"
exit(0)
q = example.intQueue(10)
print "Inserting items into intQueue"
print type(example.FullError)
try:
for i in range(0,100):
q.enqueue(i)