mirror of https://github.com/KLayout/klayout.git
* Maybe fixing issue #1619 (crash on Fedora-39 upon initialization) * Python 3.6 compatibility --------- Co-authored-by: Matthias Koefferlein <matthias@klayout.de>
This commit is contained in:
parent
9a94b5f535
commit
1eefbf35ad
|
|
@ -221,7 +221,7 @@ PythonInterpreter::PythonInterpreter (bool embedded)
|
|||
: gsi::Interpreter (0, "pya"),
|
||||
mp_current_console (0), mp_current_exec_handler (0), m_current_exec_level (0),
|
||||
m_in_trace (false), m_block_exceptions (false), m_ignore_next_exception (false),
|
||||
mp_current_frame (NULL), mp_py3_app_name (0), m_embedded (embedded)
|
||||
mp_current_frame (NULL), m_embedded (embedded)
|
||||
{
|
||||
// Don't attempt any additional initialization in the standalone module case
|
||||
if (! embedded) {
|
||||
|
|
@ -347,19 +347,16 @@ PythonInterpreter::PythonInterpreter (bool embedded)
|
|||
#else
|
||||
|
||||
// Python 3 requires a unicode string for the application name
|
||||
PyObject *an = c2python (app_path);
|
||||
tl_assert (an != NULL);
|
||||
mp_py3_app_name = PyUnicode_AsWideCharString (an, NULL);
|
||||
tl_assert (mp_py3_app_name != NULL);
|
||||
Py_DECREF (an);
|
||||
Py_SetProgramName (mp_py3_app_name);
|
||||
|
||||
mp_py3_app_name = tl::to_wstring (app_path);
|
||||
Py_SetProgramName (const_cast<wchar_t *> (mp_py3_app_name.c_str ()));
|
||||
|
||||
PyImport_AppendInittab (pya_module_name, &init_pya_module);
|
||||
Py_InitializeEx (0 /*don't set signals*/);
|
||||
|
||||
// Set dummy argv[]
|
||||
// TODO: more?
|
||||
wchar_t *argv[1] = { mp_py3_app_name };
|
||||
wchar_t *argv[1] = { const_cast<wchar_t *> (mp_py3_app_name.c_str()) };
|
||||
PySys_SetArgvEx (1, argv, 0);
|
||||
|
||||
// Import the module
|
||||
|
|
@ -396,14 +393,7 @@ PythonInterpreter::~PythonInterpreter ()
|
|||
sp_interpreter = 0;
|
||||
|
||||
if (m_embedded) {
|
||||
|
||||
Py_Finalize ();
|
||||
|
||||
if (mp_py3_app_name) {
|
||||
PyMem_Free (mp_py3_app_name);
|
||||
mp_py3_app_name = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ private:
|
|||
std::string m_debugger_scope;
|
||||
PyFrameObject *mp_current_frame;
|
||||
std::map<PyObject *, size_t> m_file_id_map;
|
||||
wchar_t *mp_py3_app_name;
|
||||
std::wstring mp_py3_app_name;
|
||||
bool m_embedded;
|
||||
std::unique_ptr<pya::PythonModule> m_pya_module;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue