changeset 363:445df7f96fbc

Use the __main__ namespace as the default global namespace for evaluating code * oct-py-eval.cc (pytave::py_run_string_safe): Use the dictionary of __main__ as the default global namespace.
author Mike Miller <mtmiller@octave.org>
date Thu, 25 Aug 2016 11:39:45 -0700
parents b0677c492655
children 1470ed26917a
files oct-py-eval.cc
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/oct-py-eval.cc	Thu Aug 25 09:51:58 2016 -0700
+++ b/oct-py-eval.cc	Thu Aug 25 11:39:45 2016 -0700
@@ -105,7 +105,9 @@
 
   if (! globals || (globals == Py_None))
     {
-      globals = PyEval_GetGlobals ();
+      PyObject *main = py_import_module ("__main__");
+      globals = PyModule_GetDict (main);
+      Py_DECREF (main);
       if (! globals)
         {
           globals = PyDict_New ();