|
|
@@ -1493,34 +1493,40 @@ static void _free_command_line(wchar_t **command_line, int num)
|
|
|
static int python_start_script(const char *script, int argc, const char **argv)
|
|
|
{
|
|
|
struct tables *tables = &tables_global;
|
|
|
+ PyMODINIT_FUNC (*initfunc)(void);
|
|
|
#if PY_MAJOR_VERSION < 3
|
|
|
const char **command_line;
|
|
|
#else
|
|
|
wchar_t **command_line;
|
|
|
#endif
|
|
|
- char buf[PATH_MAX];
|
|
|
+ /*
|
|
|
+ * Use a non-const name variable to cope with python 2.6's
|
|
|
+ * PyImport_AppendInittab prototype
|
|
|
+ */
|
|
|
+ char buf[PATH_MAX], name[19] = "perf_trace_context";
|
|
|
int i, err = 0;
|
|
|
FILE *fp;
|
|
|
|
|
|
#if PY_MAJOR_VERSION < 3
|
|
|
+ initfunc = initperf_trace_context;
|
|
|
command_line = malloc((argc + 1) * sizeof(const char *));
|
|
|
command_line[0] = script;
|
|
|
for (i = 1; i < argc + 1; i++)
|
|
|
command_line[i] = argv[i - 1];
|
|
|
#else
|
|
|
+ initfunc = PyInit_perf_trace_context;
|
|
|
command_line = malloc((argc + 1) * sizeof(wchar_t *));
|
|
|
command_line[0] = Py_DecodeLocale(script, NULL);
|
|
|
for (i = 1; i < argc + 1; i++)
|
|
|
command_line[i] = Py_DecodeLocale(argv[i - 1], NULL);
|
|
|
#endif
|
|
|
|
|
|
+ PyImport_AppendInittab(name, initfunc);
|
|
|
Py_Initialize();
|
|
|
|
|
|
#if PY_MAJOR_VERSION < 3
|
|
|
- initperf_trace_context();
|
|
|
PySys_SetArgv(argc + 1, (char **)command_line);
|
|
|
#else
|
|
|
- PyInit_perf_trace_context();
|
|
|
PySys_SetArgv(argc + 1, command_line);
|
|
|
#endif
|
|
|
|