summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ae2054)
raw | patch | inline | side by side (parent: 7ae2054)
author | Sven Trenkel <collectd@semidefinite.de> | |
Fri, 9 Jan 2015 21:28:24 +0000 (21:28 +0000) | ||
committer | Sven Trenkel <collectd@semidefinite.de> | |
Fri, 9 Jan 2015 21:28:24 +0000 (21:28 +0000) |
https://github.com/collectd/collectd/issues/505
src/collectd-python.pod | patch | blob | history | |
src/python.c | patch | blob | history |
index fc5376ed05743ae17dfdf3b7eaa5452330ae07a2..ac88f0367b981f3cc7fb53b82fd0d60b25a7e282 100644 (file)
--- a/src/collectd-python.pod
+++ b/src/collectd-python.pod
=item B<Encoding> I<Name>
The default encoding for Unicode objects you pass to collectd. If you omit this
-option it will default to B<ascii> on I<Python 2> and B<utf-8> on I<Python 3>.
-This is hardcoded in Python and will ignore everything else, including your
-locale.
+option it will default to B<ascii> on I<Python 2>. On I<Python 3> it will
+always be B<utf-8>, 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<ModulePath> I<Name>
diff --git a/src/python.c b/src/python.c
index af2dc5b69d2f84b8dc83e5895fb126078470b652..928c921bbf6274db71efe69ff9874583e9f52c70 100644 (file)
--- a/src/python.c
+++ b/src/python.c
#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();
} 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;