# HG changeset patch # User Mike Miller # Date 1472150385 25200 # Node ID 445df7f96fbca8769d91ae819aac7b0be848e62f # Parent b0677c492655ff10155e8ba812f1aacd0bd0444a 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. diff -r b0677c492655 -r 445df7f96fbc oct-py-eval.cc --- 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 ();