summaryrefslogtreecommitdiff
path: root/loaders
diff options
context:
space:
mode:
authorGarrett Regier <garrettregier@gmail.com>2013-11-12 23:00:22 -0800
committerGarrett Regier <garrettregier@gmail.com>2013-11-12 23:00:22 -0800
commitd66094c5aaa494bf7246d857f2e93c1e404e8222 (patch)
tree6c88979e722d66661cfc5e0e93a272a769f24468 /loaders
parent9a7c426a5f7b463e7d82c7ee3e801f3b4925299e (diff)
downloadlibpeas-d66094c5aaa494bf7246d857f2e93c1e404e8222.tar.gz
Print a critical warning when attempting to mix Python versions
This prevents people from trying to load python3 plugins using a python2 program and vice versa.
Diffstat (limited to 'loaders')
-rw-r--r--loaders/python/peas-plugin-loader-python.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index b7a5881..f59a0bc 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -371,6 +371,7 @@ static gboolean
peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
{
PeasPluginLoaderPython *pyloader = PEAS_PLUGIN_LOADER_PYTHON (loader);
+ long hexversion;
PyObject *mdict, *gettext, *install, *gettext_args;
const gchar *prgname;
#if PY_VERSION_HEX < 0x03000000
@@ -412,6 +413,19 @@ peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
pyloader->priv->must_finalize_python = TRUE;
}
+ hexversion = PyLong_AsLong (PySys_GetObject ((char *) "hexversion"));
+
+#if PY_VERSION_HEX < 0x03000000
+ if (hexversion >= 0x03000000)
+#else
+ if (hexversion < 0x03000000)
+#endif
+ {
+ g_critical ("Attempting to mix incompatible Python versions");
+
+ goto python_init_error;
+ }
+
prgname = g_get_prgname ();
prgname = prgname == NULL ? "" : prgname;