From: Florian Forster Date: Sat, 6 Nov 2010 11:08:20 +0000 (+0100) Subject: Merge branch 'collectd-4.9' into collectd-4.10 X-Git-Tag: collectd-4.10.2~3 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=171d6a4bd5e05b56be83860701d35bfe1373d6a7;p=collectd.git Merge branch 'collectd-4.9' into collectd-4.10 Conflicts: src/collectd.conf.in src/python.c --- 171d6a4bd5e05b56be83860701d35bfe1373d6a7 diff --cc src/python.c index 8772cd1f,16de81d4..c056b5bf --- a/src/python.c +++ b/src/python.c @@@ -962,22 -890,9 +962,23 @@@ static PyObject *cpy_oconfig_to_pyconfi return item; } +#ifdef IS_PY3K +static struct PyModuleDef collectdmodule = { + PyModuleDef_HEAD_INIT, + "collectd", /* name of module */ + "The python interface to collectd", /* module documentation, may be NULL */ + -1, + cpy_methods +}; + +PyMODINIT_FUNC PyInit_collectd(void) { + return PyModule_Create(&collectdmodule); +} +#endif + static int cpy_config(oconfig_item_t *ci) { int i; + char *argv = ""; PyObject *sys, *tb; PyObject *sys_path; PyObject *module; @@@ -1017,11 -922,10 +1018,14 @@@ cpy_log_exception("python initialization"); return 1; } + PySys_SetArgv(1, &argv); + PyList_SetSlice(sys_path, 0, 1, NULL); + +#ifdef IS_PY3K + module = PyImport_ImportModule("collectd"); +#else module = Py_InitModule("collectd", cpy_methods); /* Borrowed reference. */ +#endif PyModule_AddObject(module, "Config", (void *) &ConfigType); /* Steals a reference. */ PyModule_AddObject(module, "Values", (void *) &ValuesType); /* Steals a reference. */ PyModule_AddObject(module, "Notification", (void *) &NotificationType); /* Steals a reference. */