python: Remove deprecated use of Py_SetProgramName

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2023-11-22 16:13:30 +01:00 committed by myrtle
parent 7814f44883
commit de3d5be8f0

View File

@ -300,22 +300,14 @@ PYBIND11_EMBEDDED_MODULE(MODULE_NAME, m)
arch_wrap_python(m); arch_wrap_python(m);
} }
#ifdef MAIN_EXECUTABLE
static wchar_t *program;
#endif
void (*python_sighandler)(int) = nullptr; void (*python_sighandler)(int) = nullptr;
void init_python(const char *executable) void init_python(const char *executable)
{ {
#ifdef MAIN_EXECUTABLE #ifdef MAIN_EXECUTABLE
program = Py_DecodeLocale(executable, NULL); static const char* python_argv[1];
if (program == NULL) { python_argv[0] = executable;
fprintf(stderr, "Fatal error: cannot decode executable filename\n"); py::initialize_interpreter(true, 1, python_argv);
exit(1);
}
Py_SetProgramName(program);
py::initialize_interpreter();
py::module::import(TOSTRING(MODULE_NAME)); py::module::import(TOSTRING(MODULE_NAME));
PyRun_SimpleString("from " TOSTRING(MODULE_NAME) " import *"); PyRun_SimpleString("from " TOSTRING(MODULE_NAME) " import *");
python_sighandler = signal(SIGINT, SIG_DFL); python_sighandler = signal(SIGINT, SIG_DFL);
@ -326,7 +318,6 @@ void deinit_python()
{ {
#ifdef MAIN_EXECUTABLE #ifdef MAIN_EXECUTABLE
py::finalize_interpreter(); py::finalize_interpreter();
PyMem_RawFree(program);
#endif #endif
} }