Mercurial > pytave
diff pyeval.cc @ 335:9b862844e6b7
Enable Python print function in evaluated expressions (fixes issue #48)
* oct-py-eval.cc, oct-py-eval.h: New files.
* Makefile.am (COMMON_SOURCE_FILES, PYTAVE_HEADER_FILES): Add oct-py-eval.cc
and oct-py-eval.h to the build system.
* pyeval.cc (Fpyeval): Use pytave::py_eval_string.
* pyexec.cc (Fpyexec): Use pytave::py_exec_string.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Mon, 15 Aug 2016 15:16:24 -0700 |
parents | cee203ea6245 |
children | 77ffcaaf8000 |
line wrap: on
line diff
--- a/pyeval.cc Mon Aug 15 14:19:15 2016 -0700 +++ b/pyeval.cc Mon Aug 15 15:16:24 2016 -0700 @@ -34,6 +34,7 @@ #define PYTAVE_DO_DECLARE_SYMBOL #include "arrayobjectdefs.h" #include "exceptions.h" +#include "oct-py-eval.h" #include "oct-py-util.h" #include "python_to_octave.h" @@ -77,7 +78,6 @@ std::string code = args(0).string_value (); std::string id; - object res; Py_Initialize (); @@ -95,7 +95,9 @@ try { - res = eval (code.c_str (), main_namespace, local_namespace); + PyObject *obj = pytave::py_eval_string (code, main_namespace.ptr (), + local_namespace.ptr ()); + boost::python::object res { boost::python::handle<> (obj) }; if (nargout > 0 || ! res.is_none ()) {