Long story short: a GVariant must be wrapped into a gi.Struct subclass,
and PyGObject uses _pygi_struct_new_from_g_type() for that, but unfortunately
it is a private function (also, it uses other private functions, so copying
it code into pythonloader.c is not an option). Wading through the PyGObject
code it turns out that we can wrap the GVariant into a GValue, and instead use
pyg_value_as_pyobject(): it ends up calling _pygi_struct_new_from_g_type()
(via pygi_value_to_py_structured_type(), which is also private) for GValues
which wrap a GVariant.
This fixes issue #3
Newer versions of PyGObject warn about not using gi.require_version() before
importing a module using gi.repository.<Module>. The added code performs a
call equivalent to:
gi.require_version("WebKit2WebExtension", "4.0")
before importing "gi.repository.WebKit2WebExtension" into the Python VM.
Also, this patch moves all the boilerplate which checks Python errors into
a PY_CHECK() macro, which makes the code easier to follow.
This tentatively fixes issue #3.