# HG changeset patch # User Mike Miller # Date 1493655340 25200 # Node ID 78448e4de20a4497aae0eff2d1cf3b7967fea044 # Parent 16e79a1e96b81274b71651175a25d456c79f2ffa Ensure that sys.argv has a value (fixes issue #83) * oct-py-init.cc (pytave::py_init): Initialize sys.argv to be ['']. diff -r 16e79a1e96b8 -r 78448e4de20a oct-py-init.cc --- a/oct-py-init.cc Mon May 01 08:41:01 2017 -0700 +++ b/oct-py-init.cc Mon May 01 09:15:40 2017 -0700 @@ -37,11 +37,22 @@ namespace pytave { +#if PY_VERSION_HEX >= 0x03000000 + wchar_t *sys_argv[] { L"", nullptr }; +#else + char *sys_argv[] { "", nullptr }; +#endif + void py_init () { + bool is_initialized = Py_IsInitialized (); + Py_Initialize (); + if (! is_initialized) + PySys_SetArgvEx (1, sys_argv, 0); + // FIXME: these are only needed for Boost.Python implicit conversion // of Octave arrays to NumPy arrays boost::python::numeric::array::set_module_and_type ("numpy", "ndarray");