1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[python] set program name

This commit is contained in:
Witold Filipczyk 2021-12-14 16:38:48 +01:00
parent 3ea2609ced
commit aa586ee999

View File

@ -13,6 +13,7 @@
#include "elinks.h"
#include "config/home.h"
#include "main/main.h"
#include "main/module.h"
#include "scripting/python/core.h"
#include "scripting/python/dialogs.h"
@ -377,6 +378,7 @@ python_error:
return NULL;
}
static wchar_t *program_name;
void
init_python(struct module *module)
@ -385,6 +387,14 @@ init_python(struct module *module)
return;
}
program_name = Py_DecodeLocale(program.path, NULL);
if (program_name == NULL) {
fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
exit(1);
}
Py_SetProgramName(program_name); /* optional but recommended */
PyImport_AppendInittab("elinks", PyInit_elinks);
Py_Initialize();
@ -419,6 +429,7 @@ cleanup_python(struct module *module)
Py_XDECREF(temp);
Py_Finalize();
PyMem_RawFree(program_name);
}
}