summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@src.gnome.org>2004-11-04 20:55:42 +0000
committerJohan Dahlin <johan@src.gnome.org>2004-11-04 20:55:42 +0000
commit69cb5658d8ef6dc1ff58fa0f1e781d5b9f7cd925 (patch)
tree32e83ecbac9503a304bb0f021cd9f2d70755744e
parent1550aabd929a8b1dcf87c090528243dcf6ce94fe (diff)
downloadpygtk-69cb5658d8ef6dc1ff58fa0f1e781d5b9f7cd925.tar.gz
Use PyTuple_GetSlice and PyArg_ParseTuple here, so we can get the samePYGTK_2_4_1
* gtk/gtk.override (_wrap_gtk_dialog_add_buttons): Use PyTuple_GetSlice and PyArg_ParseTuple here, so we can get the same behavior as in add_button. Reported by Maciej Katafiasz, fixes #156707 * tests/test_dialog.py: Add test for it
-rw-r--r--ChangeLog6
-rw-r--r--gtk/gtk.override26
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/test_dialog.py15
4 files changed, 31 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 4aba9dd4..90be3ec8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2004-11-04 Johan Dahlin <johan@gnome.org>
+ * gtk/gtk.override (_wrap_gtk_dialog_add_buttons): Use
+ PyTuple_GetSlice and PyArg_ParseTuple here, so we can get the same
+ behavior as in add_button. Reported by Maciej Katafiasz, fixes #156707
+
+ * tests/test_dialog.py: Add test for it
+
* examples/gtk/filechooser.py: Fix typo
* examples/gtk/uimanager.py: Simplify
diff --git a/gtk/gtk.override b/gtk/gtk.override
index cb24bd15..8980b646 100644
--- a/gtk/gtk.override
+++ b/gtk/gtk.override
@@ -2747,28 +2747,18 @@ _wrap_gtk_dialog_add_buttons(PyGObject *self, PyObject *args)
"must pass an even number of arguments");
return NULL;
}
+
for (i = 0; i < len; i+= 2) {
- PyObject *py_text = PyTuple_GetItem(args, i);
- PyObject *py_resp = PyTuple_GetItem(args, i + 1);
+ PyObject *curr_args = PyTuple_GetSlice(args, i, i + 2);
gchar *text;
- gint resp;
-
- text = PyString_AsString(py_text);
- if (!text) {
- PyErr_Clear();
- PyErr_SetString(PyExc_TypeError,
- "button texts must be strings");
- return NULL;
- }
- resp = PyInt_AsLong(py_resp);
- if (!resp) {
- PyErr_Clear();
- PyErr_SetString(PyExc_TypeError,
- "button response codes must be integers");
+ gint response_id;
+
+ if (!PyArg_ParseTuple(curr_args, "si", &text, &response_id))
return NULL;
- }
- gtk_dialog_add_button(dialog, text, resp);
+
+ gtk_dialog_add_button(dialog, text, response_id);
}
+
Py_INCREF(Py_None);
return Py_None;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ef0b8647..48ab487b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = \
$(GTK_CFLAGS) \
-I$(top_srcdir)/gobject
-EXTRA_DIST = $(tests) common.py runtests.py
+EXTRA_DIST = $(tests) common.py runtests.py test-thread.h test-unknown.h
noinst_LTLIBRARIES = testhelper.la
linked_LIBS = testhelper.la
@@ -22,6 +22,7 @@ tests = \
conversion.py \
enum.py \
gtype.py \
+ test_dialog.py \
test_signal.py \
test_subtype.py \
test_unknown.py
diff --git a/tests/test_dialog.py b/tests/test_dialog.py
new file mode 100644
index 00000000..74fadb76
--- /dev/null
+++ b/tests/test_dialog.py
@@ -0,0 +1,15 @@
+import unittest
+
+from common import gtk
+
+class DialogTest(unittest.TestCase):
+ def testDialogAdd(self):
+ dialog = gtk.MessageDialog()
+
+ # sys.maxint + 1
+ response_id = 2147483648
+ self.assertRaises(OverflowError, dialog.add_button, "Foo", response_id)
+ self.assertRaises(OverflowError, dialog.add_buttons, "Foo", response_id)
+
+if __name__ == '__main__':
+ unittest.main()