2.99 MacOS enum support in gobject-introspection seems to be broken
Environment/Versions
- GIMP version:
master
- Package:
- Operating System: macOS
Description of the bug
All (or at least many) enums that are imported via gobject-introspection
into python
, appear to be broken.
Reproduction
Is the bug reproducible? Always
Reproduction steps:
- Run the application on Mac
- Note crash reports of python 3.9
…
Expected result: Options such as Gtk.SizeGroupMode.VERTICAL
would resolve properly.
Actual result: GType
comes back as invalid. Without patching, this causes a segfault
Additional information
This is the stack dump with a patched gobject-introspection
which does not crash when GType does not have a name.
** (process:74605): CRITICAL **: 23:06:05.798: pyg_enum_add: assertion 'typename != NULL' failed
Traceback (most recent call last):
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/gimp/2.99/plug-ins/file-openraster/file-openraster.py", line 18, in <module>
from gi.repository import Gimp
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/site-packages/gi/importer.py", line 144, in load_module
importlib.import_module('gi.repository.' + dep.split("-")[0])
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/site-packages/gi/importer.py", line 145, in load_module
dynamic_module = load_overrides(introspection_module)
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/site-packages/gi/overrides/__init__.py", line 118, in load_overrides
override_mod = importlib.import_module(override_package_name)
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/site-packages/gi/overrides/Gtk.py", line 431, in <module>
class SizeGroup(Gtk.SizeGroup):
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/site-packages/gi/overrides/Gtk.py", line 434, in SizeGroup
deprecated_defaults={'mode': Gtk.SizeGroupMode.VERTICAL},
File "/Users/lukasoberhuber/gimp299-osx-app/GIMP-2.99.app/Contents/Resources/lib/python3.9/site-packages/gi/module.py", line 139, in __getattr__
wrapper = enum_add(g_type)
SystemError: <built-in function enum_add> returned NULL without setting an error
This appears to be affecting many enums, not just Gtk.SizeGroupMode.VERTICAL
.
This is the patch file:
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 7d03485..aef2320 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -824,6 +824,8 @@ g_irepository_find_by_gtype (GIRepository *repository,
return NULL;
data.gtype_name = g_type_name (gtype);
+ if (data.gtype_name == NULL)
+ return NULL;
data.result_typelib = NULL;
/* Inside each typelib, we include the "C prefix" which acts as