GNOME Bugzilla – Bug 743514
Emit PyGIDeprecationWarning when accessing deprecated override attributes
Last modified: 2015-03-03 12:23:47 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.
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.
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
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...
Created attachment 295563 [details] [review] tests: Don't use deprecated override attributes Silences the warning fallout from patch 1
Review of attachment 295561 [details] [review]: Looks good.
Review of attachment 295562 [details] [review]: Sure
Review of attachment 295563 [details] [review]: Looks good now, thanks for cleaning that up.