Bug#484024: patch
Santiago Ruano Rincón
santiago at debian.org
Mon Jun 2 21:46:56 UTC 2008
Package: pygobject
Followup-For: Bug #484024
Content-Type: multipart/mixed; boundary="===============2093913649=="
MIME-Version: 1.0
From: =?utf-8?q?Santiago_Ruano_Rinc=C3=B3n?= <santiago at debian.org>
To: Debian Bug Tracking System <484024 at bugs.debian.org>
Subject: patch
Message-ID: <20080602214420.6790.49529.reportbug at localhost.localdomain>
X-Mailer: reportbug 3.40
Date: Mon, 02 Jun 2008 23:44:20 +0200
This is a multi-part MIME message sent by reportbug.
--===============2093913649==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Package: pygobject
Followup-For: Bug #484024
Attached is the patch that solves the problem, taken from:
https://bugs.launchpad.net/ubuntu/+source/pygobject/+bug/234810
regards,
Santiago
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.25-2-686 (SMP w/1 CPU core)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
--===============2093913649==
Content-Type: text/x-c++; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="484024.diff"
diff -urN pygobject-2.14.1.old/gobject/__init__.py pygobject-2.14.1/gobject/__init__.py
--- pygobject-2.14.1.old/gobject/__init__.py 2007-11-05 17:47:52.000000000 +0100
+++ pygobject-2.14.1/gobject/__init__.py 2008-06-02 23:27:26.000000000 +0200
@@ -57,15 +57,16 @@
cls.__gproperties__ = gproperties
- if (hasattr(cls, 'do_get_property') or
- hasattr(cls, 'do_set_property')):
+ if ('do_get_property' in cls.__dict__ or
+ 'do_set_property' in cls.__dict__):
for prop in props:
if (prop.getter != prop._default_getter or
prop.setter != prop._default_setter):
raise TypeError(
"GObject subclass %r defines do_get/set_property"
" and it also uses a property which a custom setter"
- " or getter. This is not allowed" % (cls,))
+ " or getter. This is not allowed" % (
+ cls.__name__,))
def obj_get_property(self, pspec):
name = pspec.name.replace('-', '_')
@@ -92,7 +93,6 @@
return
type_register(cls, namespace.get('__gtype_name__'))
-
_gobject._install_metaclass(GObjectMeta)
del _gobject
diff -urN pygobject-2.14.1.old/tests/test_properties.py pygobject-2.14.1/tests/test_properties.py
--- pygobject-2.14.1.old/tests/test_properties.py 2007-11-05 17:47:52.000000000 +0100
+++ pygobject-2.14.1/tests/test_properties.py 2008-06-02 23:27:26.000000000 +0200
@@ -327,6 +327,41 @@
b.prop1 = 20
self.assertEquals(b.prop1, 20)
+ def testPropertySubclassCustomSetter(self):
+ # test for #523352
+ class A(GObject):
+ def get_first(self):
+ return 'first'
+ first = gobject.property(type=str, getter=get_first)
+
+ class B(A):
+ def get_second(self):
+ return 'second'
+ second = gobject.property(type=str, getter=get_second)
+
+ a = A()
+ self.assertEquals(a.first, 'first')
+ self.assertRaises(TypeError, setattr, a, 'first', 'foo')
+
+ b = B()
+ self.assertEquals(b.first, 'first')
+ self.assertRaises(TypeError, setattr, b, 'first', 'foo')
+ self.assertEquals(b.second, 'second')
+ self.assertRaises(TypeError, setattr, b, 'second', 'foo')
+
+ def testPropertySubclassCustomSetterError(self):
+ try:
+ class A(GObject):
+ def get_first(self):
+ return 'first'
+ first = gobject.property(type=str, getter=get_first)
+
+ def do_get_property(self, pspec):
+ pass
+ except TypeError:
+ pass
+ else:
+ raise AssertionError
if __name__ == '__main__':
unittest.main()
--===============2093913649==--
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.25-2-686 (SMP w/1 CPU core)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
More information about the pkg-gnome-maintainers
mailing list