summaryrefslogtreecommitdiff
path: root/src/python-systemd/pyutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/python-systemd/pyutil.c')
-rw-r--r--src/python-systemd/pyutil.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/python-systemd/pyutil.c b/src/python-systemd/pyutil.c
index 42e7ba72cf..722c4f5b5f 100644
--- a/src/python-systemd/pyutil.c
+++ b/src/python-systemd/pyutil.c
@@ -58,3 +58,23 @@ int set_error(int r, const char* path, const char* invalid_message) {
}
return -1;
}
+
+#if PY_MAJOR_VERSION >=3 && PY_MINOR_VERSION >= 1
+int Unicode_FSConverter(PyObject* obj, void *_result) {
+ PyObject **result = _result;
+
+ assert(result);
+
+ if (!obj)
+ /* cleanup: we don't return Py_CLEANUP_SUPPORTED, so
+ * we can assume that it was PyUnicode_FSConverter. */
+ return PyUnicode_FSConverter(obj, result);
+
+ if (obj == Py_None) {
+ *result = NULL;
+ return 1;
+ }
+
+ return PyUnicode_FSConverter(obj, result);
+}
+#endif