Add API for enabling features and fixes which break compatibililty
Submitted by Simon Feltman
The idea is to provide an API which allows for turning on (or off) features in PyGObject that would break API compatibility. Similar to Python's "from future import X" statement.
It looks like there are some dead remnants of a similar API from PyGObject 2: https://git.gnome.org/browse/pygobject/tree/gi/gobjectmodule.c?id=3.11.5#n2157
This uses a dictionary which offers a fairly clean API: gi.features['X'] = True gi.features['X'] = False gi.features['X']
We just need to button it up a bit and expose it as "gi.features" which is filled out with False defaults.
Some initial features which could make use of this:
Deprecate initialize overrides (bug 705810). Since we can't actually remove the deprecated functions, it would be nice to explicitly disable the loading of them. By putting the overrides behind a logic test for classes which have these, we can improve load time performance for programs that need this speedup (Sugar OS). gi.features['skip_initializer_overrides']
Skipping array/list length arguments for callbacks (bug 652115). We currently pass the length argument explicitly to callbacks. Changing this is an API break. gi.features['skip_redundant_callback_args']
Zero copy support of arrays (bug 709976). Some API's which return GArrays coerced to Python lists would return a direct wrapper to the GArray. While the API could be made the same as a Python list, this might break some expectations callers have so it would need explicit enablement. gi.features['zero_copy_arrays']
Propagate exceptions from callbacks (bug 616279). Fixing this would break caller expectations so would require explicit enablement. gi.features['propagate_callback_exceptions']