Skip to content

gi: handle deprecated attributes in OverridesProxyModule directly

This avoids the need for per-module subclasses or using descriptors to handle each deprecation, simplifying the logic a bit.

Instead, we have OverridesProxyModule.__getattr__ warn about and return deprecated attributes, and add a __delattr__ method to handle deletion. The default __setattr__ method is fine as is, potentially shadowing deprecated attributes.

There are some visible behavioural changes here:

  1. dir(module) no longer returns class attributes of the module type. This is because I'm relying on super().__dir__() to list the attributes of the proxy module. Deprecated attributes are still there because they are added explicitly.
  2. Previously something like del GLib.ascii_strdown would fail with an AttributeError. It now succeeds, forwarding the delattr call to GLib._introspection_module. The attribute doesn't stay permanently deleted though, due to the lazy loading behaviour of IntrospectionModule.

It seems unlikely that this is unlikely to break existing users. Everything that should appear in help(module) still seems to be there.

Merge request reports

Loading