8000 Fix compiler warnings with Python3. · Pull Request #890 · collectd/collectd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix compiler warnings with Python3. #890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
2 commits merged into from Feb 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/collectd-python.pod
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ modules, e.g. "time".
=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>

Expand Down
8 changes: 7 additions & 1 deletion src/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
0