From: Sven Trenkel Date: Fri, 9 Jan 2015 21:28:24 +0000 (+0000) Subject: Fix compiler warnings with Python3. X-Git-Tag: collectd-5.5.0~83^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=920d5eaaa68c8e1184fa7066f8e962c3b4e384db;p=collectd.git Fix compiler warnings with Python3. https://github.com/collectd/collectd/issues/505 --- diff --git a/src/collectd-python.pod b/src/collectd-python.pod index fc5376ed..ac88f036 100644 --- a/src/collectd-python.pod +++ b/src/collectd-python.pod @@ -57,9 +57,11 @@ modules, e.g. "time". =item B I The default encoding for Unicode objects you pass to collectd. If you omit this -option it will default to B on I and B on I. -This is hardcoded in Python and will ignore everything else, including your -locale. +option it will default to B on I. On I it will +always be B, as this function was removed, so this will be silently +ignored. +These defaults are hardcoded in Python and will ignore everything else, +including your locale. =item B I diff --git a/src/python.c b/src/python.c index af2dc5b6..928c921b 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 = {0}; /* 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;