From: Omar Sandoval <osan...@fb.com>

async became a keyword in Python 3.7, so, e.g., create_subvolume('foo',
async=True) is now a syntax error. Fix it with the Python convention of
adding a trailing underscore to the keyword (async -> async_). This is
what several other Python libraries did to handle this.

Signed-off-by: Omar Sandoval <osan...@fb.com>
---
 libbtrfsutil/python/module.c                | 8 ++++----
 libbtrfsutil/python/subvolume.c             | 4 ++--
 libbtrfsutil/python/tests/test_subvolume.py | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libbtrfsutil/python/module.c b/libbtrfsutil/python/module.c
index 2dbdc7be..625cc9c6 100644
--- a/libbtrfsutil/python/module.c
+++ b/libbtrfsutil/python/module.c
@@ -233,22 +233,22 @@ static PyMethodDef btrfsutil_methods[] = {
         "this ID instead of the given path"},
        {"create_subvolume", (PyCFunction)create_subvolume,
         METH_VARARGS | METH_KEYWORDS,
-        "create_subvolume(path, async=False)\n\n"
+        "create_subvolume(path, async_=False)\n\n"
         "Create a new subvolume.\n\n"
         "Arguments:\n"
         "path -- string, bytes, or path-like object\n"
-        "async -- create the subvolume without waiting for it to commit to\n"
+        "async_ -- create the subvolume without waiting for it to commit to\n"
         "disk and return the transaction ID"},
        {"create_snapshot", (PyCFunction)create_snapshot,
         METH_VARARGS | METH_KEYWORDS,
-        "create_snapshot(source, path, recursive=False, read_only=False, 
async=False)\n\n"
+        "create_snapshot(source, path, recursive=False, read_only=False, 
async_=False)\n\n"
         "Create a new snapshot.\n\n"
         "Arguments:\n"
         "source -- string, bytes, path-like object, or open file descriptor\n"
         "path -- string, bytes, or path-like object\n"
         "recursive -- also snapshot child subvolumes\n"
         "read_only -- create a read-only snapshot\n"
-        "async -- create the subvolume without waiting for it to commit to\n"
+        "async_ -- create the subvolume without waiting for it to commit to\n"
         "disk and return the transaction ID"},
        {"delete_subvolume", (PyCFunction)delete_subvolume,
         METH_VARARGS | METH_KEYWORDS,
diff --git a/libbtrfsutil/python/subvolume.c b/libbtrfsutil/python/subvolume.c
index 6ecde1f6..0f893b91 100644
--- a/libbtrfsutil/python/subvolume.c
+++ b/libbtrfsutil/python/subvolume.c
@@ -322,7 +322,7 @@ PyObject *set_default_subvolume(PyObject *self, PyObject 
*args, PyObject *kwds)
 
 PyObject *create_subvolume(PyObject *self, PyObject *args, PyObject *kwds)
 {
-       static char *keywords[] = {"path", "async", "qgroup_inherit", NULL};
+       static char *keywords[] = {"path", "async_", "qgroup_inherit", NULL};
        struct path_arg path = {.allow_fd = false};
        enum btrfs_util_error err;
        int async = 0;
@@ -352,7 +352,7 @@ PyObject *create_subvolume(PyObject *self, PyObject *args, 
PyObject *kwds)
 PyObject *create_snapshot(PyObject *self, PyObject *args, PyObject *kwds)
 {
        static char *keywords[] = {
-               "source", "path", "recursive", "read_only", "async",
+               "source", "path", "recursive", "read_only", "async_",
                "qgroup_inherit", NULL,
        };
        struct path_arg src = {.allow_fd = true}, dst = {.allow_fd = false};
diff --git a/libbtrfsutil/python/tests/test_subvolume.py 
b/libbtrfsutil/python/tests/test_subvolume.py
index 0788a564..f2a4cdb8 100644
--- a/libbtrfsutil/python/tests/test_subvolume.py
+++ b/libbtrfsutil/python/tests/test_subvolume.py
@@ -202,7 +202,7 @@ class TestSubvolume(BtrfsTestCase):
         btrfsutil.create_subvolume(subvol + '6//')
         self.assertTrue(btrfsutil.is_subvolume(subvol + '6'))
 
-        transid = btrfsutil.create_subvolume(subvol + '7', async=True)
+        transid = btrfsutil.create_subvolume(subvol + '7', async_=True)
         self.assertTrue(btrfsutil.is_subvolume(subvol + '7'))
         self.assertGreater(transid, 0)
 
@@ -265,7 +265,7 @@ class TestSubvolume(BtrfsTestCase):
         btrfsutil.create_snapshot(subvol, snapshot + '2', recursive=True)
         self.assertTrue(os.path.exists(os.path.join(snapshot + '2', 
'nested/more_nested/nested_dir')))
 
-        transid = btrfsutil.create_snapshot(subvol, snapshot + '3', 
recursive=True, async=True)
+        transid = btrfsutil.create_snapshot(subvol, snapshot + '3', 
recursive=True, async_=True)
         self.assertTrue(os.path.exists(os.path.join(snapshot + '3', 
'nested/more_nested/nested_dir')))
         self.assertGreater(transid, 0)
 
-- 
2.19.1

Reply via email to