X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fpython.c;h=8b378a299994105f9a7584e0e247d7a2710e2558;hb=eab8493d114c7c209d90ac54edb7c8026c085747;hp=0fad6fa59a690a201d54d3a95fe33a3b29248222;hpb=e1812f8e5c5f91328398c66b602d07ee7c6ede51;p=collectd.git diff --git a/src/python.c b/src/python.c index 0fad6fa5..8b378a29 100644 --- a/src/python.c +++ b/src/python.c @@ -1034,13 +1034,15 @@ PyMODINIT_FUNC PyInit_collectd(void) { #endif static int cpy_init_python() { - char *argv = ""; PyObject *sys; PyObject *module; #ifdef IS_PY3K + wchar_t *argv = L""; /* Add a builtin module, before Py_Initialize */ PyImport_AppendInittab("collectd", PyInit_collectd); +#else + char *argv = ""; #endif Py_Initialize(); @@ -1117,9 +1119,13 @@ static int cpy_config(oconfig_item_t *ci) { } else if (strcasecmp(item->key, "Encoding") == 0) { if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_STRING) continue; +#ifdef IS_PY3K + NOTICE("python: \"Encoding\" was used in the config file but Python3 was used, which does not support changing encodings. Ignoring this."); +#else /* Why is this even necessary? And undocumented? */ if (PyUnicode_SetDefaultEncoding(item->values[0].value.string)) cpy_log_exception("setting default encoding"); +#endif } else if (strcasecmp(item->key, "LogTraces") == 0) { if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) continue;