summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pogonyshev <pogonyshev@gmx.net>2009-04-27 21:33:25 +0300
committerPaul Pogonyshev <pogonyshev@gmx.net>2009-04-28 16:54:21 +0300
commit38f3debf5568e8078dc41e2f6979c0dce6a19075 (patch)
tree12f77ca6b151684b03f19b162091235ab736383d
parente1cc4ee2bd408b5b8ad8d4d071ab2654786ddaba (diff)
downloadpygobject-38f3debf5568e8078dc41e2f6979c0dce6a19075.tar.gz
pygobject-38f3debf5568e8078dc41e2f6979c0dce6a19075.tar.xz
pygobject-38f3debf5568e8078dc41e2f6979c0dce6a19075.zip
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.)
-rw-r--r--docs/reference/pygio-file.xml14
-rw-r--r--gio/gfile.override39
-rw-r--r--gio/gio.defs2
-rw-r--r--tests/test_gio.py2
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 @@
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giofile--query-info-async">query_info_async</link></methodname>
- <methodparam><parameter role="keyword">callback</parameter></methodparam>
<methodparam><parameter role="keyword">attributes</parameter></methodparam>
+ <methodparam><parameter role="keyword">callback</parameter></methodparam>
<methodparam><parameter role="keyword">flags</parameter><initializer>gio.FILE_QUERY_INFO_NONE</initializer></methodparam>
<methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
@@ -3019,8 +3019,8 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
<programlisting><methodsynopsis language="python">
<methodname>query_info_async</methodname>
- <methodparam><parameter role="keyword">callback</parameter></methodparam>
<methodparam><parameter role="keyword">attributes</parameter></methodparam>
+ <methodparam><parameter role="keyword">callback</parameter></methodparam>
<methodparam><parameter role="keyword">flags</parameter><initializer>gio.FILE_QUERY_INFO_NONE</initializer></methodparam>
<methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
@@ -3029,13 +3029,13 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
<variablelist>
<varlistentry>
- <term><parameter>callback</parameter>&nbsp;:</term>
- <listitem><simpara>a GAsyncReadyCallback to call when the request is satisfied.
+ <term><parameter>attributes</parameter>&nbsp;:</term>
+ <listitem><simpara>an attribute query string.
</simpara></listitem>
</varlistentry>
<varlistentry>
- <term><parameter>attributes</parameter>&nbsp;:</term>
- <listitem><simpara>an attribute query string.
+ <term><parameter>callback</parameter>&nbsp;:</term>
+ <listitem><simpara>a GAsyncReadyCallback to call when the request is satisfied.
</simpara></listitem>
</varlistentry>
<varlistentry>
@@ -3065,7 +3065,7 @@ URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
</variablelist>
<para>
- The <methodname>query_info_async</methodname>() method Asynchronously gets the
+ The <methodname>query_info_async</methodname>() method asynchronously gets the
requested information about specified file. The result is a
<link linkend="class-giofileinfo"><classname>gio.FileInfo</classname></link>
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,
- &notify->callback,
- &attributes,
- &flags, &io_priority,
- &pycancellable,
- &notify->data))
- goto error;
+ "sO|OiOO:File.query_info_async",
+ kwlist,
+ &attributes,
+ &notify->callback,
+ &flags, &io_priority,
+ &pycancellable,
+ &notify->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,
+ &notify->callback,
+ &attributes,
+ &flags, &io_priority,
+ &pycancellable,
+ &notify->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()