diff options
| author | William S Fulton <wsf@fultondesigns.co.uk> | 2014-10-07 20:13:32 +0100 |
|---|---|---|
| committer | William S Fulton <wsf@fultondesigns.co.uk> | 2014-10-07 20:58:41 +0100 |
| commit | 808d4b4798685dbbc8515277faa573c7ce40fbc2 (patch) | |
| tree | 20c6837aa5a1df76891d0e4fb3c9fdf0a0decc78 /Examples/python | |
| parent | da394fae800ce121fb51d9c0ef2880fdce2f1b63 (diff) | |
| download | swig-808d4b4798685dbbc8515277faa573c7ce40fbc2.tar.gz | |
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.
Diffstat (limited to 'Examples/python')
| -rw-r--r-- | Examples/python/exception/example.i | 9 | ||||
| -rw-r--r-- | Examples/python/exception/runme.py | 15 | ||||
| -rw-r--r-- | Examples/python/exceptproxy/example.i | 10 | ||||
| -rw-r--r-- | Examples/python/exceptproxy/runme.py | 6 |
4 files changed, 34 insertions, 6 deletions
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: diff --git a/Examples/python/exceptproxy/example.i b/Examples/python/exceptproxy/example.i index 4a1e0bae9..0a46afbb6 100644 --- a/Examples/python/exceptproxy/example.i +++ b/Examples/python/exceptproxy/example.i @@ -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 +%} diff --git a/Examples/python/exceptproxy/runme.py b/Examples/python/exceptproxy/runme.py index a2ae55584..07e4b0a7f 100644 --- a/Examples/python/exceptproxy/runme.py +++ b/Examples/python/exceptproxy/runme.py @@ -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) |
