Python 3.11.3 (main, Apr 4 2023, 22:36:41) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> gi.__version__
'3.44.1'
>>> from gi.repository import GObject
>>> def f(): value = GObject.Value(); value.init(str); value.set_string('foo_bar'); return value.get_string()
...
>>> f()
'foo_bar'
>>> def g(): value = GObject.Value(str); value.set_string('foo_bar'); return value.get_string()
...
>>> g()
'foo_bar'
>>> def h(): value = GObject.Value(str, 'foo_bar'); return value.get_string()
...
>>> h()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in h
File "/nix/store/djwwhy19w91404zcmq54avz367b93ngv-python3-3.11.3-env/lib/python3.11/site-packages/gi/overrides/GObject.py", line 208, in __init__
self.set_value(py_value)
File "/nix/store/djwwhy19w91404zcmq54avz367b93ngv-python3-3.11.3-env/lib/python3.11/site-packages/gi/overrides/GObject.py", line 232, in set_value
gtype = self.__g_type
^^^^^^^^^^^^^
File "/nix/store/djwwhy19w91404zcmq54avz367b93ngv-python3-3.11.3-env/lib/python3.11/site-packages/gi/overrides/GObject.py", line 214, in __g_type
return _gi._gvalue_get_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Expected GValue argument.
>>> GObject.Value(str, 'foo_bar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/nix/store/djwwhy19w91404zcmq54avz367b93ngv-python3-3.11.3-env/lib/python3.11/site-packages/gi/overrides/GObject.py", line 208, in __init__
self.set_value(py_value)
File "/nix/store/djwwhy19w91404zcmq54avz367b93ngv-python3-3.11.3-env/lib/python3.11/site-packages/gi/overrides/GObject.py", line 232, in set_value
gtype = self.__g_type
^^^^^^^^^^^^^
File "/nix/store/djwwhy19w91404zcmq54avz367b93ngv-python3-3.11.3-env/lib/python3.11/site-packages/gi/overrides/GObject.py", line 214, in __g_type
return _gi._gvalue_get_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Expected GValue argument.
I’m confused because there’s a test for this: tests/test_gobject.py · 3.44.1 · GNOME / pygobject · GitLab that apparently passes fine python3.11 (#2693736) · Jobs · GNOME / pygobject · GitLab (you may need to scroll up to see the highlighted tests/test_gobject.py
line)
Are others able to reproduce this? If so, any idea why GObject.Value(str, 'foo_bar')
doesn’t work?