From: Patrick Browne Date: Tue, 30 Sep 2014 08:31:05 +0000 (+0200) Subject: feat(python-plugin): prepend instead of append ModulePath to sys.path X-Git-Tag: collectd-5.5.0~173^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0c380c5309b9d25a739707cbad80a69f755ff8d5;p=collectd.git feat(python-plugin): prepend instead of append ModulePath to sys.path When importing a module, you expect the plugin repertory to have higher priority than your site-packages. It will prevent hard to debug clashing module names problems. At least, if there is a problem, it will fail more loudly than "module did not register any config callback" --- diff --git a/src/python.c b/src/python.c index 10ac8f0d..81724c07 100644 --- a/src/python.c +++ b/src/python.c @@ -1103,8 +1103,8 @@ static int cpy_config(oconfig_item_t *ci) { cpy_log_exception("python initialization"); continue; } - if (PyList_Append(sys_path, dir_object) != 0) { - ERROR("python plugin: Unable to append \"%s\" to " + if (PyList_Insert(sys_path, 0, dir_object) != 0) { + ERROR("python plugin: Unable to prepend \"%s\" to " "python module path.", dir); cpy_log_exception("python initialization"); }