From 5f16a88a294f15434f03ce61789ebb57b65c5a5f Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 13 Apr 2012 09:23:43 +0200 Subject: [PATCH] python: update path returned by weechat.info_get('python2_bin', '') if path does not exist any more (for example after python upgrade) --- src/plugins/scripts/python/weechat-python.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index cdf20bdd1..9441b89c0 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -113,7 +113,7 @@ weechat_python_set_python2_bin () { const char *dir_separator; char *path, **paths, bin[4096]; - char *versions[] = { "2", "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", NULL }; + char *versions[] = { "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", "2", NULL }; int num_paths, i, j, rc; struct stat stat_buf; @@ -985,12 +985,24 @@ const char * weechat_python_info_cb (void *data, const char *info_name, const char *arguments) { + int rc; + struct stat stat_buf; + /* make C compiler happy */ (void) data; (void) arguments; if (weechat_strcasecmp (info_name, "python2_bin") == 0) { + if (python2_bin && (strcmp (python2_bin, "python") != 0)) + { + rc = stat (python2_bin, &stat_buf); + if ((rc != 0) || (!S_ISREG(stat_buf.st_mode))) + { + free (python2_bin); + weechat_python_set_python2_bin (); + } + } return python2_bin; }