From 53da419fb0b619ae63e568320367ee0bccff85f8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 25 Apr 2023 09:44:59 +1000 Subject: [PATCH] lang-python: update initialisation. Py_SetProgramName and PySys_SetArgv are deprecated, so use PyConfig to avoid warnings. Also enable "isolated" initialisation to see if it is a bad idea or not. Signed-off-by: NeilBrown --- lang-python.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lang-python.c b/lang-python.c index 5d30f4e3..57d1e840 100644 --- a/lang-python.c +++ b/lang-python.c @@ -2924,7 +2924,8 @@ static struct PyModuleDef edlib_mod = { void edlib_init(struct pane *ed safe) { PyObject *m; - wchar_t *argv[1]= { NULL }; + PyConfig config; + char *argv[2]= { "edlib", NULL }; if (edlib_module_path) module_dir = strdup(edlib_module_path); @@ -2934,9 +2935,11 @@ void edlib_init(struct pane *ed safe) /* This cast is for sparse, which doesn't seem to cope with L".." * FIXME */ - Py_SetProgramName((wchar_t*)L"edlib"); - Py_Initialize(); - PySys_SetArgv(0, argv); + PyConfig_InitPythonConfig(&config); + config.isolated = 1; + PyConfig_SetBytesArgv(&config, 0, argv); + Py_InitializeFromConfig(&config); + PyConfig_Clear(&config); PaneType.tp_new = PyType_GenericNew; PaneIterType.tp_new = PyType_GenericNew; -- 2.39.5