Mercurial > pytave
comparison pyexec.cc @ 423:6b9de18b4bdd
Eliminate remaining custom exception handling in favor of Octave errors
* oct-py-error.cc, oct-py-error.h (pytave::error_python_exception): New function
to generate an Octave error from an active Python error condition, based on
pytave::fetch_exception_message.
* oct-py-eval.cc (pytave::py_call_function, pytave::py_run_string_safe): Use it.
* oct-py-types.cc (pytave::make_py_dict): Likewise.
* oct-py-util.cc (pytave::py_objstore): Likewise.
* pycall.cc (Fpycall): Remove exception handling logic.
* pyeval.cc (Fpyeval): Likewise.
* pyexec.cc (Fpyexec): Likewise.
* exceptions.cc, exceptions.h: Delete.
* Makefile.am (COMMON_SOURCE_FILES, PYTAVE_HEADER_FILES): Remove them.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Thu, 04 May 2017 21:15:07 -0700 |
parents | 8247f298fd16 |
children | 3af3665348a1 |
comparison
equal
deleted
inserted
replaced
422:8247f298fd16 | 423:6b9de18b4bdd |
---|---|
25 #endif | 25 #endif |
26 | 26 |
27 #include <Python.h> | 27 #include <Python.h> |
28 #include <octave/oct.h> | 28 #include <octave/oct.h> |
29 | 29 |
30 #include "exceptions.h" | |
31 #include "oct-py-eval.h" | 30 #include "oct-py-eval.h" |
32 #include "oct-py-init.h" | 31 #include "oct-py-init.h" |
33 #include "oct-py-util.h" | 32 #include "oct-py-util.h" |
34 | 33 |
35 DEFUN_DLD (pyexec, args, , | 34 DEFUN_DLD (pyexec, args, , |
72 local_namespace = pytave::pyobject_unwrap_object (args(1)); | 71 local_namespace = pytave::pyobject_unwrap_object (args(1)); |
73 if (! local_namespace) | 72 if (! local_namespace) |
74 error ("pyexec: NAMESPACE must be a valid Python reference"); | 73 error ("pyexec: NAMESPACE must be a valid Python reference"); |
75 } | 74 } |
76 | 75 |
77 try | 76 // FIXME: figure out exec return code: |
78 { | 77 pytave::py_exec_string (code, 0, local_namespace); |
79 // FIXME: figure out exec return code: | 78 |
80 pytave::py_exec_string (code, 0, local_namespace); | |
81 } | |
82 catch (pytave::error_already_set const &) | |
83 { | |
84 std::string message = pytave::fetch_exception_message (); | |
85 error ("pyexec: %s", message.c_str ()); | |
86 } | |
87 return retval; | 79 return retval; |
88 } | 80 } |
89 | 81 |
90 /* | 82 /* |
91 %!error <NameError> | 83 %!error <NameError> |