Python console: Tab-completion fails on Gimp.
2.99 git master on Debian sid:
In the Python console, type Gimp. and then hit a TAB.
The UI seemingly hangs: there's no autocomplete and you can't type anything else. ^C, ^G, ^, ^U, backspace, don't help. I eventually did get control back once after typing lots of random characters but I can't figure out what did it and can't find a way the second time.
On stderr, it prints:
Traceback (most recent call last):
File "/home/akkana/run/gimp-master/lib/gimp/2.99/plug-ins/python-console/pyconsole.py", line 717, in do_key_press_event
return _Console.do_key_press_event(self, event)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/akkana/run/gimp-master/lib/gimp/2.99/plug-ins/python-console/pyconsole.py", line 326, in do_key_press_event
self.__complete()
File "/home/akkana/run/gimp-master/lib/gimp/2.99/plug-ins/python-console/pyconsole.py", line 470, in __complete
completions = self.complete(word)
^^^^^^^^^^^^^^^^^^^
File "/home/akkana/run/gimp-master/lib/gimp/2.99/plug-ins/python-console/pyconsole.py", line 653, in complete
s = self.completer.complete(text, i)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/rlcompleter.py", line 92, in complete
self.matches = self.attr_matches(text)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/rlcompleter.py", line 189, in attr_matches
if (value := getattr(thisobject, word, None)) is not None:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/gi/module.py", line 160, in __getattr__
setattr(wrapper, value_name, wrapper(value_info.get_value()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid enum value: 2147483648
The completer loop starting at line 652 of pyconsole.py is wrapped in a try/except that looks for NameError, but what it actually gets is ValueError 'invalid enum value: 2147483648'. So you can avoid the freeze by adding:
except ValueError as e:
return None
I'm not sure how the completer works so I'm not sure of the right solution to make autocomplete actually work on Gimp., though it would be helpful for plug-in writers (though it's not entirely necessary since I can look at Gimp.dir() )
Note that Gimp. works already; it's only when you tab as the first thing after the dot.