From 38f3debf5568e8078dc41e2f6979c0dce6a19075 Mon Sep 17 00:00:00 2001 From: Paul Pogonyshev Date: Mon, 27 Apr 2009 21:33:25 +0300 Subject: Swap first two arguments of gio.File.query_info_async() Swap the arguments for consistency with other methods. Update documentation accordingly. Take care to keep the old code (i.e. with non-swapped calling arguments) working, but don't mention that anywhere. (Bug #580490.) --- docs/reference/pygio-file.xml | 14 +++++++------- gio/gfile.override | 39 ++++++++++++++++++++++++++++++--------- gio/gio.defs | 2 +- tests/test_gio.py | 2 +- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/docs/reference/pygio-file.xml b/docs/reference/pygio-file.xml index 9c3cf87..9dfff67 100644 --- a/docs/reference/pygio-file.xml +++ b/docs/reference/pygio-file.xml @@ -302,8 +302,8 @@ query_info_async - callback attributes + callback flagsgio.FILE_QUERY_INFO_NONE io_priorityglib.PRIORITY_DEFAULT cancellableNone @@ -3019,8 +3019,8 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] query_info_async - callback attributes + callback flagsgio.FILE_QUERY_INFO_NONE io_priorityglib.PRIORITY_DEFAULT cancellableNone @@ -3029,13 +3029,13 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] - callback : - a GAsyncReadyCallback to call when the request is satisfied. + attributes : + an attribute query string. - attributes : - an attribute query string. + callback : + a GAsyncReadyCallback to call when the request is satisfied. @@ -3065,7 +3065,7 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] - The query_info_async() method Asynchronously gets the + The query_info_async() method asynchronously gets the requested information about specified file. The result is a gio.FileInfo object that contains key-value attributes (such as type or size for the file). diff --git a/gio/gfile.override b/gio/gfile.override index 52fc263..7f369c5 100644 --- a/gio/gfile.override +++ b/gio/gfile.override @@ -1015,7 +1015,7 @@ override g_file_query_info_async kwargs static PyObject * _wrap_g_file_query_info_async(PyGObject *self, PyObject *args, PyObject *kwargs) { - static char *kwlist[] = { "callback", "attributes", "flags", + static char *kwlist[] = { "attributes", "callback", "flags", "io_priority", "cancellable", "user_data", NULL }; GCancellable *cancellable; PyGObject *pycancellable = NULL; @@ -1028,14 +1028,35 @@ _wrap_g_file_query_info_async(PyGObject *self, PyObject *args, PyObject *kwargs) notify = pygio_notify_new(); if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "Os|OiOO:File.query_info_async", - kwlist, - ¬ify->callback, - &attributes, - &flags, &io_priority, - &pycancellable, - ¬ify->data)) - goto error; + "sO|OiOO:File.query_info_async", + kwlist, + &attributes, + ¬ify->callback, + &flags, &io_priority, + &pycancellable, + ¬ify->data)) { + /* To preserve compatibility with 2.16 we also allow swapped + * 'attributes' and 'callback'. FIXME: Remove for 3.0. */ + static char *old_kwlist[] = { "callback", "attributes", "flags", + "io_priority", "cancellable", "user_data", NULL }; + PyObject *exc_type, *exc_value, *exc_traceback; + + PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "Os|OiOO:File.query_info_async", + old_kwlist, + ¬ify->callback, + &attributes, + &flags, &io_priority, + &pycancellable, + ¬ify->data) + || !pygio_notify_callback_is_valid(notify)) { + /* Report the error with new parameters. */ + PyErr_Restore(exc_type, exc_value, exc_traceback); + goto error; + } + } if (!pygio_notify_callback_is_valid(notify)) goto error; diff --git a/gio/gio.defs b/gio/gio.defs index 14c44e7..033ed3e 100644 --- a/gio/gio.defs +++ b/gio/gio.defs @@ -1750,7 +1750,7 @@ ;; (define-method query_info_async (docstring - "F.query_info_async(callback, attributes, [flags, [io_priority,\n" + "F.query_info_async(attributes, callback, [flags, [io_priority,\n" " [cancellable, [user_data]]]]) -> query attributes\n" "\n" "Asynchronously gets the requested information about specified file.\n" diff --git a/tests/test_gio.py b/tests/test_gio.py index f94f2d0..7534ac0 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -221,7 +221,7 @@ class TestFile(unittest.TestCase): finally: loop.quit() - self.file.query_info_async(callback, "standard") + self.file.query_info_async("standard", callback) loop = glib.MainLoop() loop.run() -- cgit