diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2020-06-09 05:44:24 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 07:44:24 -0500 |
commit | c1f8d64f3bc73fe27527046c521c2327e8e310d8 (patch) | |
tree | d308f508366a68b00eec06729a2d90a1c977b482 /examples/SimpleVC.py | |
parent | 61734b41b7b96e7e7cbf46021a357d840d64b42e (diff) |
Language bindings: Enable catching of exceptions (#2813)
Fixes #2810. SWIG relies on throw specifiers to determine which
exceptions a method can throw. The wrappers generated by SWIG catch
those C++ exceptions and turn them into exceptions for the target
language. However, we have removed throw specifiers because they have
been deprecated in C++11, so SWIG did not know about any of our
exceptions. This commit fixes the issue using the %catches directive,
declaring that all methods may throw a CVC4::Exception or a general
exception. Note: This means that users of the language bindings will
just receive a general CVC4::Exception instead of more specific
exceptions like TypeExceptions. Given that we are planning to have a
single exception type for the new CVC4 API, this seemed like a natural
choice.
Additionally, the commit (significantly) simplifies the mapping of C++
to Java exceptions and fixes an issue with Python exceptions not
inheriting from BaseException. Finally, the commit adds API examples
for Java and Python, which demonstrate catching exceptions, and adds
Python examples as tests in our build system.
Diffstat (limited to 'examples/SimpleVC.py')
-rwxr-xr-x | examples/SimpleVC.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/examples/SimpleVC.py b/examples/SimpleVC.py index 5550974c9..50c52868b 100755 --- a/examples/SimpleVC.py +++ b/examples/SimpleVC.py @@ -16,11 +16,9 @@ ### A simple demonstration of the Python interface. Compare to the ### C++ interface in simple_vc_cxx.cpp; they are quite similar. ### -### To run, use something like: +### To run from a build directory, use something like: ### -### ln -s ../builds/src/bindings/python/CVC4.py CVC4.py -### ln -s ../builds/src/bindings/python/.libs/CVC4.so _CVC4.so -### ./SimpleVC.py +### PYTHONPATH=src/bindings/python python ../examples/SimpleVC.py #### import CVC4 @@ -61,4 +59,3 @@ def main(): if __name__ == '__main__': sys.exit(main()) - |