[pygobject/pygobject-3-10] Revert "Add type checking to positional Gtk.Box and Gtk.Window ctor arguments"



commit 9f913abdfa46af3c6ddf2fd35f1fb0e08d7791d4
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Nov 11 14:34:12 2013 +0100

    Revert "Add type checking to positional Gtk.Box and Gtk.Window ctor arguments"
    
    While this enforces correctness, this can cause new crashes in software which
    incorrectly uses the GObject constructor and needs fixing. E. g. Ubuntu's
    current sofware-center (wrongly) does
    
      Gtk.Box(Gtk.Orientation.HORIZONTAL)
    
    which now causes a crash with this new check.
    
    This reverts commit 2cc4dfaf877f202977de4a7ede24aa3bad7d91c8.

 gi/overrides/Gtk.py         |    7 -------
 tests/test_overrides_gtk.py |   18 ------------------
 tests/test_properties.py    |    9 ---------
 3 files changed, 0 insertions(+), 34 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 9f08492..e774c0c 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -330,10 +330,6 @@ __all__.append('ComboBox')
 
 class Box(Gtk.Box):
     def __init__(self, homogeneous=False, spacing=0, **kwds):
-        if not isinstance(homogeneous, bool):
-            raise TypeError('homogeneous argument must be of type bool')
-        if not isinstance(spacing, int):
-            raise TypeError('spacing argument must be of type int')
         super(Box, self).__init__(**kwds)
         self.set_homogeneous(homogeneous)
         self.set_spacing(spacing)
@@ -440,9 +436,6 @@ class Window(Gtk.Window):
         if not initialized:
             raise RuntimeError("Gtk couldn't be initialized")
 
-        if not isinstance(type, Gtk.WindowType):
-            raise TypeError('type argument must be of type Gtk.WindowType')
-
         # type is a construct-only property; if it is already set (e. g. by
         # GtkBuilder), do not try to set it again and just ignore it
         try:
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 681234a..fd97908 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -590,24 +590,6 @@ class TestGtk(unittest.TestCase):
         GLib.timeout_add(100, Gtk.main_quit, 'hello')
         Gtk.main()
 
-    def test_gobject_ctor_positional_args(self):
-        # GObject constructor must only allow keyword args, except for the ones
-        # which have overrides
-
-        # overridden, but no custom constructor
-        self.assertRaises(TypeError, Gtk.Widget, 1)
-        self.assertRaises(TypeError, Gtk.Container, 1)
-
-        # no overrides at all
-        self.assertRaises(TypeError, Gtk.FileChooserWidget,
-                          Gtk.FileChooserAction.SELECT_FOLDER)
-        self.assertRaises(TypeError, Gtk.Assistant, 1)
-
-    def test_gobject_ctor_unknown_property(self):
-        # GObject constructor must refuse unknown properties
-        self.assertRaises(TypeError, Gtk.Widget, unknown_prop=1)
-        self.assertRaises(TypeError, Gtk.Button, unknown_prop='a')
-
 
 @unittest.skipUnless(Gtk, 'Gtk not available')
 class TestSignals(unittest.TestCase):
diff --git a/tests/test_properties.py b/tests/test_properties.py
index ec9ddf1..ef6b867 100644
--- a/tests/test_properties.py
+++ b/tests/test_properties.py
@@ -481,15 +481,6 @@ class TestPropertyObject(unittest.TestCase):
         self.assertEqual(normal, "foo")
         self.assertEqual(uint64, 7)
 
-    def test_positional_args(self):
-        # GObject constructor must only allow keyword args
-        self.assertRaises(TypeError, new, PropertyObject, None)
-        self.assertRaises(TypeError, new, PropertyObject, "hello", 2)
-
-    def test_unknown_constructor_property(self):
-        # GObject constructor must refuse unknown properties
-        self.assertRaises(TypeError, new, PropertyObject, unknown_prop=1)
-
 
 class TestProperty(unittest.TestCase):
     def test_simple(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]