summaryrefslogtreecommitdiff
path: root/systemd/pyutil.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-07-17 12:50:13 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-07-05 14:19:20 -0400
commit2bfb849c70ac2328d37755f1850fc7cfde1d6b4d (patch)
tree6327e6a91b4891c793769f4442ce5c1efad31fa0 /systemd/pyutil.c
parent2c0317be82aa85911fe7665719d0139ee4330211 (diff)
downloadpython-systemd-2bfb849c70ac2328d37755f1850fc7cfde1d6b4d.tar.gz
systemd-python: add support for sd_j_open_files
Also export missing flags.
Diffstat (limited to 'systemd/pyutil.c')
-rw-r--r--systemd/pyutil.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/systemd/pyutil.c b/systemd/pyutil.c
index 42e7ba7..722c4f5 100644
--- a/systemd/pyutil.c
+++ b/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