diff options
author | Patrick Monnerat <[email protected]> | 2019-01-19 01:20:47 +0100 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2019-01-30 15:59:28 -0500 |
commit | 047c35bf0aaec2601d6e26e5ab479eeccc58f640 (patch) | |
tree | 7879f33a5eee365488b3de8ee530562d0d8f1be0 /src/caja-python.c | |
parent | 1eeb21507d8ab6f063d0f3a6c42c067404c03ac3 (diff) | |
download | python-caja-047c35bf0aaec2601d6e26e5ab479eeccc58f640.tar.bz2 python-caja-047c35bf0aaec2601d6e26e5ab479eeccc58f640.tar.xz |
Implement Python 3 C API compatibility using conditional and macros.
The updated sources are still compatible with Python 2.
Diffstat (limited to 'src/caja-python.c')
-rw-r--r-- | src/caja-python.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/caja-python.c b/src/caja-python.c index 7f13e36..4a310a4 100644 --- a/src/caja-python.c +++ b/src/caja-python.c @@ -31,6 +31,12 @@ #include <libcaja-extension/caja-extension-types.h> +#if PY_MAJOR_VERSION >= 3 +#define STRING_FROMSTRING(str) PyUnicode_FromString(str) +#else +#define STRING_FROMSTRING(str) PyString_FromString(str) +#endif + static const GDebugKey caja_python_debug_keys[] = { {"misc", CAJA_PYTHON_DEBUG_MISC}, }; @@ -145,7 +151,7 @@ caja_python_load_dir (GTypeModule *module, /* sys.path.insert(0, dirname) */ sys_path = PySys_GetObject("path"); - py_path = PyString_FromString(dirname); + py_path = STRING_FROMSTRING(dirname); PyList_Insert(sys_path, 0, py_path); Py_DECREF(py_path); } @@ -159,7 +165,11 @@ caja_python_init_python (void) { PyObject *gi, *require_version, *args, *caja; GModule *libpython; +#if PY_MAJOR_VERSION >= 3 + wchar_t *argv[] = { L"caja", NULL }; +#else char *argv[] = { "caja", NULL }; +#endif if (Py_IsInitialized()) return TRUE; |