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 686559 - Move property install function into propertyhelper.py
Move property install function into propertyhelper.py
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-10-21 02:55 UTC by Simon Feltman
Modified: 2012-10-22 08:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Move property install function into propertyhelper.py (8.56 KB, patch)
2012-10-21 02:58 UTC, Simon Feltman
none Details | Review
Move property install function into propertyhelper.py (8.57 KB, patch)
2012-10-21 03:00 UTC, Simon Feltman
none Details | Review
Move property install function into propertyhelper.py (8.32 KB, patch)
2012-10-22 01:47 UTC, Simon Feltman
committed Details | Review
Change install_properties to not use getattr on classes (2.35 KB, patch)
2012-10-22 02:01 UTC, Simon Feltman
committed Details | Review

Description Simon Feltman 2012-10-21 02:55:21 UTC
This ticket for a re-factoring task to move gi/_gobject/__init__.py:_install_properties into gi/_gobject/propertyhelper.py
Comment 1 Simon Feltman 2012-10-21 02:58:59 UTC
Created attachment 226914 [details] [review]
Move property install function into propertyhelper.py

A minor re-factoring which move _install_properties into
gi/_gobject/propertyhelper.py. Also fixes the same potential
problem seen with: https://bugzilla.gnome.org/show_bug.cgi?id=686496
As well as adds a handful of unittest and regression tests.
Comment 2 Simon Feltman 2012-10-21 03:00:39 UTC
Created attachment 226915 [details] [review]
Move property install function into propertyhelper.py

A minor re-factoring which moves _install_properties into
gi/_gobject/propertyhelper.py. Also fixes the same potential
problem seen with: https://bugzilla.gnome.org/show_bug.cgi?id=686496
A handful of unittest and regression tests were added as well.
Comment 3 Paolo Borelli 2012-10-21 09:54:28 UTC
Review of attachment 226915 [details] [review]:

While I do not understand in detail the intricacies of the property decorator etc, the patch looks like a good and safe refactoring with the added bonus of unit tests.

My only suggestion would be to split the commit in two steps: first the change for the problem similar to bug 686496 and then the refactoring. If we ever have to bisect it would be very hard to spot the changed line in a large block moved from a file to another
Comment 4 Simon Feltman 2012-10-22 01:47:36 UTC
Created attachment 226951 [details] [review]
Move property install function into propertyhelper.py

A minor re-factoring which moves _install_properties into
gi/_gobject/propertyhelper.py and dded a handful of unittests.
Comment 5 Simon Feltman 2012-10-22 02:01:44 UTC
Created attachment 226952 [details] [review]
Change install_properties to not use getattr on classes

This changes an issue of using getattr to pull in a classes
__gproperties__ dictionary. The issue with this is it will it will
pull the class attribute off of base class if it is not defined
in the given class. Changed to use cls.__dict__.get('__gproperties__')
instead.
Comment 6 Simon Feltman 2012-10-22 02:10:51 UTC
Thanks Paolo,

I agree, refactoring should not simultaneously include change in behavior. In this case the refactoring was needed to write good tests. I ended up breaking the refactoring out into a first patch which moves the code but keeps the same functionality and adds unittests. The second patch fixes the problem and updates the tests making it more obvious the behavior was changed.

Something else to note here is the issue we saw in https://bugzilla.gnome.org/show_bug.cgi?id=686496 is being masked in regards to properties do to type registration in C deleting __gproperties__ off of the type being registered (which also seems a bit odd). These patches ensure things will be correct regardless of what happens on the C side.
Comment 7 Martin Pitt 2012-10-22 05:27:21 UTC
Comment on attachment 226952 [details] [review]
Change install_properties to not use getattr on classes

Hello Simon,

the patch looks good to me, but I have some nitpicks with the changelog:

>This changes an issue of using getattr to pull in a classes
>__gproperties__ dictionary.

This sentence doesn't explain much, I think you can just drop it.

> The issue with this is it will it will

Just one "it will". But simplifying this to "This will" is enough IMHO :-)

> pull the class attribute off of base class if it is not defined
>in the given class.

Can the changelog please explain why this is bad? Some pointers to bugs, etc.

> Changed to use cls.__dict__.get('__gproperties__') instead.

Please use the present tense consistently (just drop the "Changed to").
Comment 8 Martin Pitt 2012-10-22 05:29:55 UTC
Comment on attachment 226951 [details] [review]
Move property install function into propertyhelper.py

Nice cleanup, thanks!

> A minor re-factoring which moves _install_properties into

"Move _install_properties() into"

> gi/_gobject/propertyhelper.py and dded a handful of unittests.

Missing "a", and please use present tense consistently, so "add".

Please go ahead with these changes, thanks!
Comment 9 Simon Feltman 2012-10-22 08:39:21 UTC
Pushed with changelog fixes.