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 743514 - Emit PyGIDeprecationWarning when accessing deprecated override attributes
Emit PyGIDeprecationWarning when accessing deprecated override attributes
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 665084
 
 
Reported: 2015-01-26 07:57 UTC by Christoph Reiter (lazka)
Modified: 2015-03-03 12:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch v1 (17.19 KB, patch)
2015-01-26 07:57 UTC, Christoph Reiter (lazka)
accepted-commit_now Details | Review
Emit PyGIDeprecationWarning when accessing deprecated override attributes. (17.84 KB, patch)
2015-01-27 17:54 UTC, Christoph Reiter (lazka)
committed Details | Review
Add GLib.MINFLOAT etc. and mark GObject.G_MINFLOAT etc. deprecated. (3.01 KB, patch)
2015-01-27 17:57 UTC, Christoph Reiter (lazka)
committed Details | Review
tests: Don't use deprecated override attributes (55.67 KB, patch)
2015-01-27 17:58 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Christoph Reiter (lazka) 2015-01-26 07:57:55 UTC
Created attachment 295423 [details] [review]
patch v1

Adds a new helper function for overrides to mark a module level attribute
as deprecated. A warning will be emitted every time the attribute gets
accessed.

e.g. when marking GObject.STATUS_FOO as deprecated using

   STATUS_FOO = GLib.Status.FOO
   deprecated_attr("GObject", "STATUS_FOO", "GLib.Status.FOO")
   __all__.append("STATUS_FOO")

accessing it will emit

  "GObject.STATUS_FOO is deprecated; use GLib.Status.FOO instead"

############################

What this changes is instead of creating a OverridesProxyModule instance per override it creates a OverridesProxyModule sub class and instance and replaces deprecated attributes on the instance with descriptors on the sub class which act as values but emit a warning on access.
Comment 1 Simon Feltman 2015-01-27 06:39:59 UTC
Review of attachment 295423 [details] [review]:

Nice work, thanks! there is quite a bit of fallout in the test suite though, see:
    $ make check 2>&1 | grep "GObject\.G_M"

::: gi/overrides/__init__.py
@@ +32,2 @@
     def __init__(self, introspection_module):
+        types.ModuleType.__init__(self, introspection_module.__name__)

was this change needed for the added functionality? if not it should probably go in its own commit.
Comment 2 Christoph Reiter (lazka) 2015-01-27 17:54:49 UTC
Created attachment 295561 [details] [review]
Emit PyGIDeprecationWarning when accessing deprecated override attributes.

Thanks, the types.ModuleType.__init__ change was not actually needed and a left over of a previous approach.

Further changes:

* Remove unneeded double assignment of deprecated attributes in the previous patch (they are set by global()[])

* Don't depend on GObjectModule.ParamFlags.READWRITE which is only available in newer glib. GObject.PARAM_READWRITE will only be marked deprecated if ParamFlags.READWRITE is available
Comment 3 Christoph Reiter (lazka) 2015-01-27 17:57:53 UTC
Created attachment 295562 [details] [review]
Add GLib.MINFLOAT etc. and mark GObject.G_MINFLOAT etc. deprecated.

This is mainly for the next patch so I could replace the G_MAX/MIN usage in the tests more easily...
Comment 4 Christoph Reiter (lazka) 2015-01-27 17:58:53 UTC
Created attachment 295563 [details] [review]
tests: Don't use deprecated override attributes

Silences the warning fallout from patch 1
Comment 5 Simon Feltman 2015-03-01 05:08:14 UTC
Review of attachment 295561 [details] [review]:

Looks good.
Comment 6 Simon Feltman 2015-03-01 05:10:49 UTC
Review of attachment 295562 [details] [review]:

Sure
Comment 7 Simon Feltman 2015-03-01 05:23:58 UTC
Review of attachment 295563 [details] [review]:

Looks good now, thanks for cleaning that up.