After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 586181 - gobject::propertyhelper::property has name collisions to the new python property methods
gobject::propertyhelper::property has name collisions to the new python prope...
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other All
: Normal minor
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2009-06-17 23:54 UTC by Ronny Pfannschmidt
Modified: 2012-03-15 12:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Renamed getter/setter instance attributes. (7.95 KB, patch)
2012-03-13 08:59 UTC, Simon Feltman
committed Details | Review

Description Ronny Pfannschmidt 2009-06-17 23:54:25 UTC
recent python versions added the methods getter/setter/deleter to propperties to help composing them in the class namespaces

this directly clashes with the gobject property, which uses getter/setter for the get/set functions,

Other information:
http://docs.python.org/library/functions.html#property
Comment 1 Simon van der Linden 2011-01-17 17:29:23 UTC
Don't import property from gobject into the global namespace; use gobject.property instead to avoid name clashes.
Comment 2 Ronny Pfannschmidt 2011-01-19 16:48:52 UTC
i didn't mean the name of the class

but the names of its attributes, which class with utility methods of property
Comment 3 Simon van der Linden 2011-01-19 17:02:30 UTC
I don't get it. Can you provide an example please?
Comment 4 Ronny Pfannschmidt 2011-01-19 19:07:43 UTC
the problem target is the following idiom:

class test(object):

    @property
    def foo(self):
        ...

    @foo.setter
    def foo(self, val):
        ...

it works with python's property, but it cannot wok with gobject's property since gobject properties mask those attributes instead of following the convention of pythons builtin properties (fget/set/del for the functions, setter/getter/deleter for the decorator utilities)
Comment 5 Simon Feltman 2012-03-13 08:59:03 UTC
Created attachment 209583 [details] [review]
Renamed getter/setter instance attributes.

Renamed getter/setter instance attributes and added getter/setter methods to the GObject.property class to match that of the python property class and allow for decoratored setter methods. In addition, __call__ was added to allow an instantiated decorator with args to also decorate a method. The following works with this patch:

class C(GObject.GObject):
    _value = 0
    @GObject.property(type=int, default=0)
    def propInt(self):
        return self._value
    @propInt.setter
    def propInt(self, value):
        self._value = value
Comment 6 Martin Pitt 2012-03-15 12:18:27 UTC
Very nice, thank you! Committed.