pygobject issueshttps://gitlab.gnome.org/GNOME/pygobject/-/issues2024-03-27T22:15:21Zhttps://gitlab.gnome.org/GNOME/pygobject/-/issues/627Support creating Gio.File.new_for_path from pathlib.Path2024-03-27T22:15:21ZMaximilianoSupport creating Gio.File.new_for_path from pathlib.PathOn gnome-nightly:
```
>>> import gi
>>> from pathlib import Path
>>> from gi.repository import Gio
>>> Gio.File.new_for_path(Path("foo"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Must be bytes, ...On gnome-nightly:
```
>>> import gi
>>> from pathlib import Path
>>> from gi.repository import Gio
>>> Gio.File.new_for_path(Path("foo"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Must be bytes, not PosixPath
>>>
```https://gitlab.gnome.org/GNOME/pygobject/-/issues/625from gi.repository import Gtk crashes on MacOS 13.2 (22D49)2024-03-25T12:52:57ZRigel Youngfrom gi.repository import Gtk crashes on MacOS 13.2 (22D49)environment:
python3.12
pygobject3.46.0_1
gtk3.24.41
reproduce:
brew install pygobject3
brew gtk3.24.41
enter python3 and execute: from gi.repository import Gtk
then something goes wrong:
```
>>> from gi.repository import Gtk
/opt/hom...environment:
python3.12
pygobject3.46.0_1
gtk3.24.41
reproduce:
brew install pygobject3
brew gtk3.24.41
enter python3 and execute: from gi.repository import Gtk
then something goes wrong:
```
>>> from gi.repository import Gtk
/opt/homebrew/lib/python3.12/site-packages/gi/module.py:168: Warning: cannot register existing type 'AtkImplementorIface'
g_type = info.get_g_type()
/opt/homebrew/lib/python3.12/site-packages/gi/module.py:203: Warning: g_type_get_qdata: assertion 'node != NULL' failed
type_ = g_type.pytype
/opt/homebrew/lib/python3.12/site-packages/gi/types.py:247: Warning: cannot register existing type 'AtkImplementorIface'
register_interface_info(cls.__info__.get_g_type())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 921, in _load_unlocked
File "<frozen importlib._bootstrap>", line 813, in module_from_spec
File "/opt/homebrew/lib/python3.12/site-packages/gi/importer.py", line 147, in create_module
dynamic_module = load_overrides(introspection_module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/gi/overrides/__init__.py", line 118, in load_overrides
override_mod = importlib.import_module(override_package_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/gi/overrides/Gtk.py", line 100, in <module>
class Widget(Gtk.Widget):
^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/gi/module.py", line 173, in __getattr__
interfaces = tuple(interface for interface in get_interfaces_for_object(info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/gi/module.py", line 95, in get_interfaces_for_object
interfaces.append(getattr(module, name))
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/gi/module.py", line 213, in __getattr__
wrapper = metaclass(name, bases, dict_)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.12/site-packages/gi/types.py", line 247, in __init__
register_interface_info(cls.__info__.get_g_type())
TypeError: must be an interface
```https://gitlab.gnome.org/GNOME/pygobject/-/issues/6243.47 broke gst-python build tests2024-03-23T15:30:24ZJeremy Bicha3.47 broke gst-python build testsgst-python's build tests are failing.
This issue was originally reported at https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3353
The issue was bisected back to https://gitlab.gnome.org/GNOME/pygobject/-/commit/7f6b68459a636...gst-python's build tests are failing.
This issue was originally reported at https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3353
The issue was bisected back to https://gitlab.gnome.org/GNOME/pygobject/-/commit/7f6b68459a636b717a2c6cae7b2154a3c1462215https://gitlab.gnome.org/GNOME/pygobject/-/issues/621Cant call gsk_path_get_closest_point2024-03-25T07:33:36ZMaximilianoCant call gsk_path_get_closest_pointCalling this fn returns
```
Traceback (most recent call last):
File "/var/home/deathwish/Downloads/test/test.py", line 23, in on_activate
crash()
File "/var/home/deathwish/Downloads/test/test.py", line 18, in crash
_found, ...Calling this fn returns
```
Traceback (most recent call last):
File "/var/home/deathwish/Downloads/test/test.py", line 23, in on_activate
crash()
File "/var/home/deathwish/Downloads/test/test.py", line 18, in crash
_found, end, _end_d = path.get_closest_point(p, 5)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Could not caller allocate argument 3 of callable Gsk.Path.get_closest_point
```
A simple reproducer
```python
#!/usr/bin/env python3
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk, GObject, Gio, GLib, Graphene, Gsk
def crash():
path_builder = Gsk.PathBuilder.new()
path_builder.line_to(0, 1)
path_builder.line_to(1, 1)
path_builder.line_to(1, 0)
path_builder.close()
path = path_builder.to_path()
p = Graphene.Point().alloc()
p.init(2, 0)
_found, end, _end_d = path.get_closest_point(p, 5)
def on_activate(app):
window = Gtk.ApplicationWindow(application=app)
window.present()
crash()
app = Gtk.Application()
app.connect("activate", on_activate)
app.run()
```
Here is the definition of the fn
```c
/**
* gsk_path_get_closest_point:
* @self: a `GskPath`
* @point: the point
* @threshold: maximum allowed distance
* @result: (out caller-allocates): return location for the closest point
* @distance: (out) (optional): return location for the distance
*
* Computes the closest point on the path to the given point
* and sets the @result to it.
*
* If there is no point closer than the given threshold,
* `FALSE` is returned.
*
* Returns: `TRUE` if @point was set to the closest point
* on @self, `FALSE` if no point is closer than @threshold
*
* Since: 4.14
*/
gboolean
gsk_path_get_closest_point (GskPath *self,
const graphene_point_t *point,
float threshold,
GskPathPoint *result,
float *distance)
```
and
```c
G_DEFINE_BOXED_TYPE (GskPathPoint, gsk_path_point,
gsk_path_point_copy,
gsk_path_point_free)
```https://gitlab.gnome.org/GNOME/pygobject/-/issues/6203.46.0: test suite fails in tests/test_atoms.py::TestGdkAtom::test_in_array unit2024-02-11T11:45:57ZTomasz Kłoczko3.46.0: test suite fails in tests/test_atoms.py::TestGdkAtom::test_in_array unit<details>
<summary>Here is test suite output:</summary>
```console
+ cd pygobject-3.46.0
+ dbus-run-session -- xvfb-run -a /usr/bin/meson test -C x86_64-redhat-linux-gnu --num-processes 48 --print-errorlogs
ninja: Entering directory `/h...<details>
<summary>Here is test suite output:</summary>
```console
+ cd pygobject-3.46.0
+ dbus-run-session -- xvfb-run -a /usr/bin/meson test -C x86_64-redhat-linux-gnu --num-processes 48 --print-errorlogs
ninja: Entering directory `/home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/x86_64-redhat-linux-gnu'
ninja: no work to do.
1/1 pygobject-test-suite FAIL 8.62s exit status 1
>>> ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 LD_LIBRARY_PATH=/home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/x86_64-redhat-linux-gnu/tests MALLOC_PERTURB_=173 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 GI_TYPELIB_PATH=/home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/x86_64-redhat-linux-gnu/tests PYTHONPATH=/home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/x86_64-redhat-linux-gnu/tests/..:/home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/x86_64-redhat-linux-gnu/subprojects/pycairo TESTS_BUILDDIR=/home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/x86_64-redhat-linux-gnu/tests /usr/bin/python3 /home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/tests/runtests.py
――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――
============================= test session starts ==============================
platform linux -- Python 3.8.18, pytest-8.0.0, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0
collected 1482 items
../tests/test_atoms.py .F..... [ 0%]
../tests/test_cairo.py .............................. [ 2%]
../tests/test_docstring.py ................x. [ 3%]
../tests/test_error.py ............... [ 4%]
../tests/test_everything.py ......................x..................... [ 7%]
........................................................................ [ 12%]
........... [ 13%]
../tests/test_fields.py ................ [ 14%]
../tests/test_gdbus.py ............ [ 15%]
../tests/test_generictreemodel.py ................... [ 16%]
../tests/test_gi.py .................................................... [ 19%]
..........................................................s............. [ 24%]
........................................................................ [ 29%]
...................................s..ss.....s...........s.............. [ 34%]
........................................................................ [ 39%]
............................................................x........... [ 44%]
................. [ 45%]
../tests/test_gio.py ..................... [ 46%]
../tests/test_glib.py ................x.... [ 48%]
../tests/test_gobject.py ............................................... [ 51%]
...... [ 51%]
../tests/test_gtk_template.py ...................... [ 53%]
../tests/test_gtype.py ................ [ 54%]
../tests/test_gtype_instance.py . [ 54%]
../tests/test_import_machinery.py ............ [ 55%]
../tests/test_interface.py .. [ 55%]
../tests/test_internal_api.py ............. [ 56%]
../tests/test_iochannel.py ................... [ 57%]
../tests/test_mainloop.py .. [ 57%]
../tests/test_object_marshaling.py ............................ [ 59%]
../tests/test_option.py .......... [ 60%]
../tests/test_ossig.py .......... [ 60%]
../tests/test_overrides_gdk.py ........s.......s...s.. [ 62%]
../tests/test_overrides_gdkpixbuf.py .. [ 62%]
../tests/test_overrides_gio.py ............. [ 63%]
../tests/test_overrides_glib.py .s......s...................... [ 65%]
../tests/test_overrides_gobject.py ......................... [ 67%]
../tests/test_overrides_gtk.py ...................................s..... [ 70%]
ss..s....s.x..........ss................................................ [ 74%]
....... [ 75%]
../tests/test_overrides_pango.py ....... [ 75%]
../tests/test_properties.py ............................................ [ 78%]
............x...........................x...................... [ 83%]
../tests/test_pycapi.py . [ 83%]
../tests/test_pygtkcompat.py .................................. [ 85%]
../tests/test_repository.py ........................... [ 87%]
../tests/test_resulttuple.py ........ [ 87%]
../tests/test_signal.py ................x................x.............. [ 91%]
..........................................s............................. [ 95%]
.......x....x.. [ 96%]
../tests/test_source.py ......................... [ 98%]
../tests/test_subprocess.py ..x........ [ 99%]
../tests/test_thread.py . [ 99%]
../tests/test_typeclass.py ...... [ 99%]
../tests/test_unknown.py ... [100%]
=================================== FAILURES ===================================
__________________________ TestGdkAtom.test_in_array ___________________________
self = <tests.test_atoms.TestGdkAtom testMethod=test_in_array>
def test_in_array(self):
a_plain = Gdk.Atom.intern('text/plain', False)
a_html = Gdk.Atom.intern('text/html', False)
a_jpeg = Gdk.Atom.intern('image/jpeg', False)
self.assertFalse(Gtk.targets_include_text([]))
self.assertTrue(Gtk.targets_include_text([a_plain, a_html]))
self.assertFalse(Gtk.targets_include_text([a_jpeg]))
self.assertTrue(Gtk.targets_include_text([a_jpeg, a_plain]))
self.assertFalse(Gtk.targets_include_image([], False))
self.assertFalse(Gtk.targets_include_image([a_plain, a_html], False))
> self.assertTrue(Gtk.targets_include_image([a_jpeg], False))
E AssertionError: False is not true
../tests/test_atoms.py:67: AssertionError
=============================== warnings summary ===============================
tests/test_overrides_gdkpixbuf.py::test_new_from_data_deprecated_args
/home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/gi/overrides/GdkPixbuf.py:42: PyGIDeprecationWarning: destroy_fn argument deprecated
warnings.warn(w)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED ../tests/test_atoms.py::TestGdkAtom::test_in_array - AssertionError: F...
====== 1 failed, 1450 passed, 19 skipped, 12 xfailed, 1 warning in 8.13s =======
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Summary of Failures:
1/1 pygobject-test-suite FAIL 8.62s exit status 1
Ok: 0
Expected Fail: 0
Fail: 1
Unexpected Pass: 0
Skipped: 0
Timeout: 0
Full log written to /home/tkloczko/rpmbuild/BUILD/pygobject-3.46.0/x86_64-redhat-linux-gnu/meson-logs/testlog.txt
```
</details>https://gitlab.gnome.org/GNOME/pygobject/-/issues/616`g_param_spec_string` parameters cannot be set to non-utf-8 strings?2024-03-25T09:26:05Znagisa`g_param_spec_string` parameters cannot be set to non-utf-8 strings?I have been taking a look at how to resolve an [issue around filename handling in beets](https://github.com/beetbox/beets/issues/3513). Namely, beets uses `gstreamer` and sets the `location` parameter of `GstFileSrc` to a file path. This...I have been taking a look at how to resolve an [issue around filename handling in beets](https://github.com/beetbox/beets/issues/3513). Namely, beets uses `gstreamer` and sets the `location` parameter of `GstFileSrc` to a file path. This parameter is a `g_param_spec_string`.
It so happens that sometimes paths in the filesystem will not be UTF-8 encoded, which beets seems to convert into strings with UTF-8 surrogates in them before they are set to a property. These strings then fail to convert in, I believe, an eventual call to `pygi_utf8_from_py`. I also tried to set the parameter to a bytestring (`b"..."`) or a list of bytes (`[1, 2, 3]`), but in either case a debug representation of these values are getting used instead, rather than the underlying bytes.
In practice beets already holds the file system paths as byte strings and it would be great if it was able to set the property up with the bytestring in the first place. However, I can’t seem to be able to find a way to do so. Is there a way to do so, and if not, would it make sense to add a way to do something like this?https://gitlab.gnome.org/GNOME/pygobject/-/issues/614Adding bindings to custom widgets causes them to never get destroyed2024-03-27T15:00:15ZknuxifyAdding bindings to custom widgets causes them to never get destroyedTake the following program:
```python
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk, Gio, GObject, GLib
class MyItem(GObject.Object):
__gtype_name__ = 'MyItem'
name = GObject.Property(type=str)
clas...Take the following program:
```python
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk, Gio, GObject, GLib
class MyItem(GObject.Object):
__gtype_name__ = 'MyItem'
name = GObject.Property(type=str)
class MyLabel(Gtk.Label):
__gtype_name__ = 'MyLabel'
factory_xml = """
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="GtkListItem">
<property name="child">
<object class="MyLabel">
<property name="wrap">true</property>
<property name="wrap-mode">word-char</property>
<binding name="label">
<lookup name="name" type="MyItem">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface>
"""
window_xml = """
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="MyWindow" parent="GtkApplicationWindow">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="entry"/>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="vexpand">true</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListView" id="list_view"/>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
"""
@Gtk.Template.from_string(window_xml)
class MyWindow(Gtk.ApplicationWindow):
__gtype_name__ = 'MyWindow'
list_view = Gtk.Template.Child()
entry = Gtk.Template.Child()
def __init__(self, app):
super().__init__(application=app)
test_model = Gio.ListStore.new(MyItem)
for i in range(1, 100):
item = MyItem()
item.props.name = 'asdf' * i
test_model.append(item)
self.filter = Gtk.CustomFilter.new(self.filter_func)
test_filter_model = Gtk.FilterListModel.new(test_model, self.filter)
self.entry.connect('search-changed', self.update_filter)
factory = Gtk.BuilderListItemFactory.new_from_bytes(None, GLib.Bytes.new(str.encode(factory_xml)))
self.list_view.set_model(Gtk.SingleSelection.new(test_filter_model))
self.list_view.set_factory(factory)
def update_filter(self, *args):
self.filter.changed(Gtk.FilterChange.DIFFERENT)
def filter_func(self, item, *args):
query = self.entry.get_text()
return query in item.name
def on_activate(app):
win = MyWindow(app)
win.present()
if __name__ == "__main__":
app = Gtk.Application(application_id='com.example.GtkApplication')
app.connect('activate', on_activate)
app.run()
```
If you type something into the search entry (that isn't contained in the generated labels - e.g. `gggg`), then remove your query, the memory usage will start to quickly rise. The longer you repeat this, the higher the memory usage will go.
If you replace "MyLabel" with "GtkLabel" in line 19 (in the factory XML), and do the same thing, memory will rise and fall accordingly to the amount of labels on-screen.
Tested with Python 3.11.6, PyGObject 3.46.0, GTK 4.12.4, GLib 2.78.3, on Alpine Linux edge.https://gitlab.gnome.org/GNOME/pygobject/-/issues/613GDBus.Error:org.gnome.SessionManager.GeneralError: Invalid inhibit flags2023-12-09T18:39:44ZsigmaSdGDBus.Error:org.gnome.SessionManager.GeneralError: Invalid inhibit flagsthis next code gives this warning (when clicking the button) `(python:42515): Gtk-WARNING **: 13:06:30.318: Calling org.gnome.SessionManager.Inhibit failed: GDBus.Error:org.gnome.SessionManager.GeneralError: Invalid inhibit flags`
```py...this next code gives this warning (when clicking the button) `(python:42515): Gtk-WARNING **: 13:06:30.318: Calling org.gnome.SessionManager.Inhibit failed: GDBus.Error:org.gnome.SessionManager.GeneralError: Invalid inhibit flags`
```py
#!/usr/bin/env python3
import gi
gi.require_version('Adw', '1')
gi.require_version('Gtk', '4.0')
from gi.repository import Adw, Gdk, Gio, Gtk
class MainWindow(Gtk.ApplicationWindow):
def __init__(self, app):
super().__init__(application=app)
self.app = app
self.button = Gtk.ToggleButton(label="OFF")
self.button.connect("clicked", self.r)
self.set_child(self.button)
def r(self, button):
self.app.inhibit(self, Gtk.ApplicationInhibitFlags.IDLE)
class App(Adw.Application):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.connect("activate", self.on_activate)
self.win = None
def on_activate(self, _app):
self.win = MainWindow(self)
self.win.present()
if __name__ == "__main__":
import os
app = App(application_id="io.todo.todo")
app.run([])
```
And with the same code when run inside a flatpak pkg I get even more warnings
```
/app/bin/a.py:16: Warning: g_variant_new_string: assertion 'string != NULL' failed
self.app.inhibit(self, Gtk.ApplicationInhibitFlags.IDLE)
/app/bin/a.py:16: Warning: g_variant_new_variant: assertion 'value != NULL' failed
self.app.inhibit(self, Gtk.ApplicationInhibitFlags.IDLE)
/app/bin/a.py:16: Warning: g_variant_get_type: assertion 'value != NULL' failed
self.app.inhibit(self, Gtk.ApplicationInhibitFlags.IDLE)
/app/bin/a.py:16: Warning: g_variant_type_is_subtype_of: assertion 'g_variant_type_check (type)' failed
self.app.inhibit(self, Gtk.ApplicationInhibitFlags.IDLE)
/app/bin/a.py:16: Warning: g_variant_builder_add_value: assertion '!GVSB(builder)->expected_type || g_variant_is_of_type (value, GVSB(builder)->expected_type)' failed
self.app.inhibit(self, Gtk.ApplicationInhibitFlags.IDLE)
/app/bin/a.py:16: Warning: g_variant_builder_end: assertion 'GVSB(builder)->offset >= GVSB(builder)->min_items' failed
self.app.inhibit(self, Gtk.ApplicationInhibitFlags.IDLE)
```https://gitlab.gnome.org/GNOME/pygobject/-/issues/611Add overrides for GdkRGBA and in particular GdkRGBA.parse()2024-01-03T02:55:08ZBenjamin OtteAdd overrides for GdkRGBA and in particular GdkRGBA.parse()This is a followup of https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6599
In particular of https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6599#note_1933413 and the following comments.
GTK4 has a function called `gdk_rgba_parse...This is a followup of https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6599
In particular of https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/6599#note_1933413 and the following comments.
GTK4 has a function called `gdk_rgba_parse()` that's supposed to be treated as a @staticmethod in languages like Python, but it is not.
Current code requires:
```
color = Gdk.RGBA().parse("#ff0000")
```
as opposed to
```
color = Gdk.RGBA.parse("#ff0000")
```
While looking through the code, it seems that https://gitlab.gnome.org/GNOME/pygobject/-/blob/master/gi/overrides/Gdk.py has overrides for GdkRGBA - but they only exist for GTK3, and not GTK4. Should those overrides be enabled for GTK4, too?https://gitlab.gnome.org/GNOME/pygobject/-/issues/609Move documentation to a more central location2024-02-04T18:11:46ZDan YeawMove documentation to a more central locationRight now the documentation is in multiple locations, can be hard to find, and it doesn't appear very official:
1. The main docs are at https://pygobject.readthedocs.io. This is very common for the Python ecosystem to use RTD.
2. The la...Right now the documentation is in multiple locations, can be hard to find, and it doesn't appear very official:
1. The main docs are at https://pygobject.readthedocs.io. This is very common for the Python ecosystem to use RTD.
2. The latest API docs are at https://amolenaar.pages.gitlab.gnome.org/pygobject-docs/
3. The PyGObject Guide is at https://rafaelmardojai.pages.gitlab.gnome.org/pygobject-guide/
I recommend we get a URL at https://gnome.pages.gitlab.gnome.org/pygobject/ that could contain all these resources.https://gitlab.gnome.org/GNOME/pygobject/-/issues/608Warning "expected enumeration type void, but got PyGLibOptionArg instead"2024-01-30T13:47:39ZlovetoxWarning "expected enumeration type void, but got PyGLibOptionArg instead"Since my last OS upgrade to Ubuntu 23.10 i get now this warning whenever i start my app.
```
** (launch.py:23598): WARNING **: 22:12:16.698: expected enumeration type void, but got PyGLibOptionArg instead
```
i have a backtrace but it ...Since my last OS upgrade to Ubuntu 23.10 i get now this warning whenever i start my app.
```
** (launch.py:23598): WARNING **: 22:12:16.698: expected enumeration type void, but got PyGLibOptionArg instead
```
i have a backtrace but it does not tell me much. I dont find `PyGLibOptionArg` in either GLib or pygobject codebase .. no idea where it comes from.
```
Thread 1 "gajim" received signal SIGTRAP, Trace/breakpoint trap.
g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd7f0) at ../../../glib/gmessages.c:1423
Downloading source file /usr/src/glib2.0-2.78.0-2/debian/build/deb/../../../glib/gmessages.c
1423 g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
(gdb) bt
#0 g_logv (log_domain=0x0, log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd7f0) at ../../../glib/gmessages.c:1423
#1 0x00007ffff6da5ca3 in g_log
(log_domain=log_domain@entry=0x0, log_level=log_level@entry=G_LOG_LEVEL_WARNING, format=format@entry=0x7ffff6ecb070 "expected enumeration type %s, but got %s instead")
at ../../../glib/gmessages.c:1461
#2 0x00007ffff6eb8eed in pyg_enum_get_value (enum_type=Python Exception <class 'gdb.error'>: value has been optimized out
, obj=<optimized out>, val=<optimized out>) at gi/pygi-type.c:602
#3 0x00007ffff6ea9016 in _pygi_argument_from_object (object=0x7fffdf9c3d30, type_info=0x17086e0, transfer=GI_TRANSFER_EVERYTHING) at gi/pygi-argument.c:497
#4 0x00007ffff6eb1df0 in _wrap_g_field_info_set_value (self=0x7fffdf99f5a0, args=<optimized out>) at gi/pygi-info.c:2132
#5 0x00000000005127a0 in cfunction_call (func=0x7fffdf9d8270, args=<optimized out>, kwargs=<optimized out>) at ../Objects/methodobject.c:553
#6 0x00000000004e0bab in _PyObject_MakeTpCall (tstate=0xa70a38 <_PyRuntime+166328>, callable=0x7fffdf9d8270, args=<optimized out>, nargs=2, keywords=0x0)
at ../Objects/call.c:214
#7 0x00000000005e46ea in property_descr_set (self=0x7fffdf9d82c0, obj=<optimized out>, value=<optimized out>) at ../Objects/descrobject.c:1681
#8 0x00000000004d6b0b in _PyObject_GenericSetAttrWithDict (obj=obj@entry=0x7fffdf9c3890, name=name@entry=0x7ffff740fbf0, value=value@entry=0x7fffdf9c3d30, dict=dict@entry=0x0)
at ../Objects/object.c:1398
#9 0x00000000004d628e in PyObject_GenericSetAttr (value=0x7fffdf9c3d30, name=0x7ffff740fbf0, obj=0x7fffdf9c3890) at ../Objects/object.c:1457
#10 PyObject_SetAttr (v=0x7fffdf9c3890, name=0x7ffff740fbf0, value=0x7fffdf9c3d30) at ../Objects/object.c:1028
#11 0x00000000004f9a6d in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:2874
#12 0x00000000004e8ef7 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb3198, tstate=0xa70a38 <_PyRuntime+166328>) at ../Include/internal/pycore_ceval.h:73
#13 _PyEval_Vector (kwnames=0x0, argcount=<optimized out>, args=0x7fffffffddc0, locals=0x0, func=0x7fffdf9cbce0, tstate=0xa70a38 <_PyRuntime+166328>) at ../Python/ceval.c:6425
#14 _PyFunction_Vectorcall (kwnames=0x0, nargsf=<optimized out>, stack=0x7fffffffddc0, func=0x7fffdf9cbce0) at ../Objects/call.c:393
#15 _PyObject_FastCallDictTstate (tstate=0xa70a38 <_PyRuntime+166328>, callable=0x7fffdf9cbce0, args=0x7fffffffddc0, nargsf=<optimized out>, kwargs=<optimized out>)
at ../Objects/call.c:141
#16 0x000000000052eace in _PyObject_Call_Prepend
(kwargs=0x0, args=0xa56698 <_PyRuntime+58904>, obj=<optimized out>, callable=0x7fffdf9cbce0, tstate=0xa70a38 <_PyRuntime+166328>) at ../Objects/call.c:482
#17 slot_tp_init (self=<optimized out>, args=<optimized out>, kwds=<optimized out>) at ../Objects/typeobject.c:7854
#18 0x00000000004e0b4e in type_call (kwds=0x0, args=0xa56698 <_PyRuntime+58904>, type=<optimized out>) at ../Objects/typeobject.c:1103
#19 _PyObject_MakeTpCall (tstate=0xa70a38 <_PyRuntime+166328>, callable=0x16f9ba0, args=<optimized out>, nargs=<optimized out>, keywords=0x0) at ../Objects/call.c:214
#20 0x00000000004f627a in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:4760
#21 0x00000000005d99bf in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb3020, tstate=0xa70a38 <_PyRuntime+166328>) at ../Include/internal/pycore_ceval.h:73
#22 _PyEval_Vector (args=0x0, argcount=0, kwnames=0x0, locals=<optimized out>, func=0x7ffff75d1f80, tstate=0xa70a38 <_PyRuntime+166328>) at ../Python/ceval.c:6425
#23 PyEval_EvalCode (co=0x7ffff7441f30, globals=<optimized out>, locals=<optimized out>) at ../Python/ceval.c:1140
#24 0x00000000005f7fc7 in run_eval_code_obj (tstate=0xa70a38 <_PyRuntime+166328>, co=0x7ffff7441f30, globals=0x7ffff75f3400, locals=0x7ffff75f3400) at ../Python/pythonrun.c:1710
#25 0x00000000005f49c3 in run_mod (mod=<optimized out>, filename=<optimized out>, globals=0x7ffff75f3400, locals=0x7ffff75f3400, flags=<optimized out>, arena=<optimized out>)
at ../Python/pythonrun.c:1731
#26 0x0000000000608896 in pyrun_file
--Type <RET> for more, q to quit, c to continue without paging--
(fp=0xadc490, filename=0x7ffff7335050, start=<optimized out>, globals=0x7ffff75f3400, locals=0x7ffff75f3400, closeit=1, flags=0x7fffffffe1c8) at ../Python/pythonrun.c:1626
#27 0x00000000006085e1 in _PyRun_SimpleFileObject (fp=fp@entry=0xadc490, filename=filename@entry=0x7ffff7335050, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1c8)
at ../Python/pythonrun.c:440
#28 0x00000000006083b4 in _PyRun_AnyFileObject (fp=0xadc490, filename=filename@entry=0x7ffff7335050, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe1c8)
at ../Python/pythonrun.c:79
#29 0x000000000060690f in pymain_run_file_obj (skip_source_first_line=0, filename=0x7ffff7335050, program_name=0x7ffff75f35f0) at ../Modules/main.c:360
#30 pymain_run_file (config=0xa56a80 <_PyRuntime+59904>) at ../Modules/main.c:379
#31 pymain_run_python (exitcode=0x7fffffffe1c4) at ../Modules/main.c:601
#32 Py_RunMain () at ../Modules/main.c:680
#33 0x00000000005cb9db in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at ../Modules/main.c:734
#34 0x00007ffff7c280d0 in __libc_start_call_main (main=main@entry=0x5cb940 <main>, argc=argc@entry=2, argv=argv@entry=0x7fffffffe3f8)
at ../sysdeps/nptl/libc_start_call_main.h:58
#35 0x00007ffff7c28189 in __libc_start_main_impl
(main=0x5cb940 <main>, argc=2, argv=0x7fffffffe3f8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe3e8)
at ../csu/libc-start.c:360
#36 0x00000000005cb875 in _start ()
```https://gitlab.gnome.org/GNOME/pygobject/-/issues/606Possible memory corruption with GLib.Regex.match2023-11-13T06:47:28ZZachary SamplePossible memory corruption with GLib.Regex.match```py
import gi
gi.require_version("GLib", "2.0")
from gi.repository import GLib
s = "hello"
r = GLib.Regex.new(s, 0, 0)
(success, match) = r.match(s, 0)
assert success, "should match"
try:
groups = match.fetch_all()
print(grou...```py
import gi
gi.require_version("GLib", "2.0")
from gi.repository import GLib
s = "hello"
r = GLib.Regex.new(s, 0, 0)
(success, match) = r.match(s, 0)
assert success, "should match"
try:
groups = match.fetch_all()
print(groups)
except UnicodeDecodeError as e:
print(e)
try:
groups = match.fetch_all()
print(groups)
except UnicodeDecodeError as e:
print(e)
```
Running this file on my machine prints a `UnicodeDecodeError` on the first `try` block, and then crashes with "double free or corruption (out)" on the second `match.fetch_all()` call.
```sh
(venv)$ python3 main.py
'utf-8' codec can't decode byte 0x90 in position 0: invalid start byte
double free or corruption (out)
Aborted (core dumped)
```
Running the code in a REPL gives different results for the first `fetch_all()` call (not always exactly reproducible).
```py
(venv)$ python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> gi.require_version("GLib", "2.0")
>>> from gi.repository import GLib
>>> s = "hello"
>>> r = GLib.Regex.new(s, 0, 0)
>>> (success, match) = r.match(s, 0)
>>> assert success
>>> groups = match.fetch_all()
>>> groups
['en_US']
>>> groups = match.fetch_all()
double free or corruption (out)
Aborted (core dumped)
```
I haven't looked into it, but my guess is that the returned `MatchInfo` is referencing a string which has been freed.
> `string` is not copied and is used in `GMatchInfo` internally. If you use any `GMatchInfo` method (except `g_match_info_free()`) after freeing or modifying string then the behaviour is undefined.
(from https://docs.gtk.org/glib/method.Regex.match.html)
----
Versions:
```sh
(venv)$ pip list
Package Version
---------- -------
pip 22.0.2
pycairo 1.25.1
PyGObject 3.46.0
setuptools 59.6.0
```
Xubuntu 22.04 system, with `libglib2.0-0` version `2.72.4-0ubuntu2.2`, running in a Python3 3.10.12 venv with PyGObject freshly installed.https://gitlab.gnome.org/GNOME/pygobject/-/issues/605Unexpected ownership transfer within a get_property call2023-11-08T16:21:09ZRobert AyrapetyanUnexpected ownership transfer within a get_property callSystem artifacts:
```plaintext
Package: python3-gi
Source: pygobject (3.42.2-3)
Version: 3.42.2-3+b1
```
```plaintext
Package: python3-gst-1.0
Source: gst-python1.0
Version: 1.22.0-2
```
Code demonstrating the issue:
```python
import...System artifacts:
```plaintext
Package: python3-gi
Source: pygobject (3.42.2-3)
Version: 3.42.2-3+b1
```
```plaintext
Package: python3-gst-1.0
Source: gst-python1.0
Version: 1.22.0-2
```
Code demonstrating the issue:
```python
import traceback
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GLib
def consumer_added_callback(wrs, peer_id, webrtcbin):
print('Consumer {} added'.format(webrtcbin))
print('before get_property')
iceagent = webrtcbin.get_property("ice-agent")
print(iceagent)
print('after get_property')
# Initializes Gstreamer, it's variables, paths
Gst.init(sys.argv)
# Create a new pipeline
pipeline = Gst.Pipeline()
# Creates element by name
# https://lazka.github.io/pgi-docs/Gst-1.0/classes/ElementFactory.html#Gst.ElementFactory.make
src_name = "my_video_test_src"
src = Gst.ElementFactory.make("videotestsrc", "my_video_test_src")
wrs = Gst.ElementFactory.make("webrtcsink", "wrs")
wrs.set_property("name", "wrs")
signaller = wrs.get_property("signaller")
signaller.set_property("uri", "ws://gst-webrtc-signalling-service:8443")
pipeline.add(src)
pipeline.add(wrs)
src.link(wrs)
wrs.connect('consumer-added', consumer_added_callback)
# Start pipeline
pipeline.set_state(Gst.State.PLAYING)
# Init GObject loop to handle Gstreamer Bus Events
loop = GLib.MainLoop()
try:
loop.run()
except Exception:
traceback.print_exc()
loop.quit()
# Stop Pipeline
pipeline.set_state(Gst.State.NULL)
del pipeline
```
The **`iceagent`** reference is being invalidated as it exits the scope of the **`consumer_added_callback`** function, leading to the subsequent destruction of the underlying **`iceagent`** object, which ultimately causes a failure in the pipeline. Making `iceagent` **global** resolves the issue. But it looks like a bug in a binders reference counter logic.https://gitlab.gnome.org/GNOME/pygobject/-/issues/604set_keep_below() makes buttons unclickable2024-03-17T13:37:10ZShaiq Mustafaset_keep_below() makes buttons unclickableI am trying to create a rain meter like widget. When I use the option set_keep_below(True) in my python code, it makes the button on my widget unclickable. Otherwise the window stays on top of all other windows. Heres some of the code:
...I am trying to create a rain meter like widget. When I use the option set_keep_below(True) in my python code, it makes the button on my widget unclickable. Otherwise the window stays on top of all other windows. Heres some of the code:
```python
### Code for the class with the buttons ###
class NowPlayingWidget(Gtk.Grid):
def __init__(self):
super().__init__()
self.set_name('now-playing')
self.set_row_spacing(10)
self.set_column_spacing(10)
self.set_halign(Gtk.Align.CENTER)
self.set_valign(Gtk.Align.CENTER)
self.now_playing_label = Gtk.Label()
self.now_playing_label.set_name('now-playing-label')
self.now_playing_label.set_halign(Gtk.Align.CENTER)
self.now_playing_label.set_valign(Gtk.Align.CENTER)
self.attach(self.now_playing_label, 0, 0, 2, 1) # Centered label over two columns
self.artist_label = Gtk.Label() # Add an artist label
self.artist_label.set_name('artist-label')
self.artist_label.set_halign(Gtk.Align.CENTER)
self.attach(self.artist_label, 0, 1, 2, 1) # Centered artist label over two columns
self.progress_bar = Gtk.ProgressBar()
self.progress_bar.set_hexpand(True)
self.attach(self.progress_bar, 0, 2, 2, 1) # Centered progress bar over two columns
self.current_time_label = Gtk.Label()
self.current_time_label.set_name('current-time-label')
self.current_time_label.set_halign(Gtk.Align.START)
self.attach(self.current_time_label, 0, 3, 1, 1)
self.total_time_label = Gtk.Label()
self.total_time_label.set_name('total-time-label')
self.total_time_label.set_halign(Gtk.Align.END)
self.attach(self.total_time_label, 1, 3, 1, 1)
# Create a separate container for the buttons
buttons_box = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL, spacing=20)
buttons_box.set_halign(Gtk.Align.CENTER)
buttons_box.set_valign(Gtk.Align.CENTER)
self.attach(buttons_box, 0, 4, 2, 1) # Place the button container below the main interface
# Create buttons for play, pause, next, and previous
prev_button = Gtk.Button()
prev_button.set_halign(Gtk.Align.START)
prev_button.set_valign(Gtk.Align.CENTER)
prev_button.get_style_context().add_class("button") # Apply the "button" class to the button
prev_button_image = Gtk.Image.new_from_icon_name("media-seek-backward", Gtk.IconSize.BUTTON)
prev_button_image.get_style_context().add_class("icon") # Apply the "icon" class to the button's image
prev_button.add(prev_button_image)
prev_button.get_style_context().add_class('button')
prev_button.connect("clicked", self.prev_media)
prev_button.connect("enter-notify-event", self.on_hover)
prev_button.connect("leave-notify-event", self.on_leave)
buttons_box.add(prev_button)
play_button = Gtk.Button()
play_button.set_halign(Gtk.Align.START)
play_button.set_valign(Gtk.Align.CENTER)
play_button.get_style_context().add_class("button") # Apply the "button" class to the button
play_button_image = Gtk.Image.new_from_icon_name("media-playback-start", Gtk.IconSize.BUTTON)
play_button_image.get_style_context().add_class("icon") # Apply the "icon" class to the button's image
play_button.add(play_button_image)
play_button.get_style_context().add_class('button')
play_button.connect("clicked", self.play_media)
play_button.connect("enter-notify-event", self.on_hover)
play_button.connect("leave-notify-event", self.on_leave)
buttons_box.add(play_button)
buttons_box.add(play_button)
pause_button = Gtk.Button()
pause_button.set_halign(Gtk.Align.START)
pause_button.set_valign(Gtk.Align.CENTER)
pause_button.get_style_context().add_class("button")
pause_button_image = Gtk.Image.new_from_icon_name("media-playback-pause", Gtk.IconSize.BUTTON)
pause_button_image.get_style_context().add_class("icon")
pause_button.add(pause_button_image)
pause_button.get_style_context().add_class('button')
pause_button.connect("clicked", self.pause_media)
pause_button.connect("enter-notify-event", self.on_hover)
pause_button.connect("leave-notify-event", self.on_leave)
buttons_box.add(pause_button)
buttons_box.add(pause_button)
next_button = Gtk.Button()
next_button.set_halign(Gtk.Align.START)
next_button.set_valign(Gtk.Align.CENTER)
next_button.get_style_context().add_class("button") # Apply the "button" class to the button
next_button_image = Gtk.Image.new_from_icon_name("media-seek-forward", Gtk.IconSize.BUTTON)
next_button_image.get_style_context().add_class("icon") # Apply the "icon" class to the button's image
next_button.add(next_button_image)
next_button.get_style_context().add_class('button')
next_button.connect("clicked", self.next_media)
next_button.connect("enter-notify-event", self.on_hover)
next_button.connect("leave-notify-event", self.on_leave)
buttons_box.add(next_button)
buttons_box.add(next_button)
self.update_song_info()
##....
## OTHER CODE AND METHODS###
### Heres the driver code ###
class Run():
def __init__(self):
style_provider = Gtk.CssProvider()
style_provider.load_from_path('styles.css')
win = Gtk.Window(name='toplevel')
win.set_title('Desktop Clock')
win.set_position(Gtk.WindowPosition.CENTER)
win.set_default_size(600, 500)
win.set_decorated(False)
win.set_skip_taskbar_hint(True)
win.set_skip_pager_hint(True)
win.set_keep_below(True)
win.connect('destroy', Gtk.main_quit)
screen = win.get_screen()
visual = screen.get_rgba_visual()
if visual:
win.set_visual(visual)
else:
print('Your screen may not support transparency')
grid = Gtk.Grid()
grid.set_name('grid')
grid.set_column_homogeneous(True)
clock_widget = clock_date.DesktopClockWidget()
now_playing_widget = now_playing.NowPlayingWidget()
weather_widget = weather_data.WeatherWidget()
weather_widget.set_margin_top(40) # Adjust the pixel value as needed
grid.attach(clock_widget, 0, 0, 1, 1)
grid.attach(now_playing_widget, 0, 1, 1, 1)
grid.attach(weather_widget, 0, 2, 1, 1)
win.add(grid)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
win.show_all()
Gtk.main()
```
I want to understand why the buttons are disabled when the window goes back, the cursor doesnt change either as it does otherwise.https://gitlab.gnome.org/GNOME/pygobject/-/issues/603TlsConnection.get_channel_binding_data() segfaults2023-10-30T17:46:56ZlovetoxTlsConnection.get_channel_binding_data() segfaultsHi,
When i call this method after successful TLS connection i receive a segfault
```
Thread 1 "gajim" received signal SIGFPE, Arithmetic exception.
0x00007ffff6d85fd0 in g_array_maybe_expand (array=array@entry=0x1b6f810, len=len@entry=...Hi,
When i call this method after successful TLS connection i receive a segfault
```
Thread 1 "gajim" received signal SIGFPE, Arithmetic exception.
0x00007ffff6d85fd0 in g_array_maybe_expand (array=array@entry=0x1b6f810, len=len@entry=32) at ../../../glib/garray.c:1103
Downloading source file /usr/src/glib2.0-2.76.1-1/debian/build/deb/../../../glib/garray.c
1103 max_len = MIN (G_MAXSIZE / 2 / array->elt_size, G_MAXUINT) - array->zero_terminated;
(gdb) bt
#0 0x00007ffff6d85fd0 in g_array_maybe_expand (array=array@entry=0x1b6f810, len=len@entry=32) at ../../../glib/garray.c:1103
#1 0x00007ffff6d86610 in g_array_append_vals (farray=farray@entry=0x1b6f810, data=0x2204670, len=32) at ../../../glib/garray.c:643
#2 0x00007ffff6d8668d in g_byte_array_append (array=array@entry=0x1b6f810, data=<optimized out>, len=<optimized out>)
at ../../../glib/garray.c:2995
#3 0x00007fffd30a1439 in gnutls_get_binding (gnutls=<optimized out>, data=0x1b6f810, binding=<optimized out>, error=0x7fffffffcad8)
at ../tls/gnutls/gtlsconnection-gnutls.c:1165
#4 0x00007ffff7e118b6 in ffi_call_unix64 () at ../src/x86/unix64.S:104
#5 0x00007ffff7e0e34d in ffi_call_int
(cif=cif@entry=0x245ed58, fn=<optimized out>, rvalue=<optimized out>, avalue=<optimized out>, closure=closure@entry=0x0)
at ../src/x86/ffi64.c:673
#6 0x00007ffff7e10f33 in ffi_call (cif=cif@entry=0x245ed58, fn=<optimized out>, rvalue=rvalue@entry=0x7fffffffca38, avalue=<optimized out>)
at ../src/x86/ffi64.c:710
#7 0x00007ffff6ecd356 in pygi_invoke_c_callable
(function_cache=0x245ecb0, state=<optimized out>, py_args=<optimized out>, py_kwargs=<optimized out>) at gi/pygi-invoke.c:684
#8 0x00007ffff6ecb600 in pygi_function_cache_invoke (py_kwargs=0x0, py_args=0x7fffd0c85400, function_cache=<optimized out>) at gi/pygi-cache.c:862
#9 pygi_callable_info_invoke (user_data=0x0, cache=<optimized out>, kwargs=0x0, py_args=0x7fffd0c85400, info=<optimized out>)
at gi/pygi-invoke.c:727
#10 _wrap_g_callable_info_invoke (self=<optimized out>, py_args=py_args@entry=0x7fffd0c85400, kwargs=kwargs@entry=0x0) at gi/pygi-invoke.c:764
#11 0x00007ffff6ecb835 in _callable_info_call (self=0x7fffd3fcc930, args=0x7fffd17c4f10, kwargs=0x0) at gi/pygi-info.c:548
#12 0x00000000004ea513 in _PyObject_MakeTpCall
(tstate=0xa820b8 <_PyRuntime+166328>, callable=0x7fffd3fcc930, args=<optimized out>, nargs=1, keywords=0x0) at ../Objects/call.c:214
#13 0x00000000004ff354 in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>)
at ../Python/ceval.c:4774
#14 0x000000000055d27c in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb54b0, tstate=0xa820b8 <_PyRuntime+166328>)
at ../Include/internal/pycore_ceval.h:73
#15 _PyEval_Vector
(kwnames=<optimized out>, argcount=<optimized out>, args=0x7fffffffcd90, locals=0x0, func=0x7ffff5d498a0, tstate=0xa820b8 <_PyRuntime+166328>)
at ../Python/ceval.c:6439
#16 _PyFunction_Vectorcall (kwnames=<optimized out>, nargsf=<optimized out>, stack=0x7fffffffcd90, func=0x7ffff5d498a0) at ../Objects/call.c:393
#17 _PyObject_VectorcallTstate
(tstate=0xa820b8 <_PyRuntime+166328>, callable=0x7ffff5d498a0, args=0x7fffffffcd90, nargsf=<optimized out>, kwnames=<optimized out>)
```https://gitlab.gnome.org/GNOME/pygobject/-/issues/602Python errors should be captured in boxed_dealloc2024-01-01T21:52:28ZJames CowgillPython errors should be captured in boxed_deallocIn my application I have a scenario where the free function of one of my boxed types ends up calling into some Cython code elsewhere (all this code is unrelated to PyGObject).
If I raise an exception in Python that results in one of the...In my application I have a scenario where the free function of one of my boxed types ends up calling into some Cython code elsewhere (all this code is unrelated to PyGObject).
If I raise an exception in Python that results in one of these types being released, the `boxed_dealloc` function is called with a pending exception and the Cython code that is eventually called complains about an unhandled exception and clears the exception. This breaks my application which does not raise the Python exception as it should.
To fix this I think Python exceptions should be saved in `boxed_dealloc` (or maybe just the code path that calls `g_boxed_free`).
Very similar to this commit but for boxed types: https://gitlab.gnome.org/GNOME/pygobject/-/commit/288ad4c7e0a13a43992014f5fff55636c7c8fcfdhttps://gitlab.gnome.org/GNOME/pygobject/-/issues/598Remove code demos from repository?2023-10-05T22:18:57ZMatRemove code demos from repository?The demos present in the "examples" folder are still stuck on GTK 3, and are becoming increasingly less useful due to demonstrating either deprecated or outdated widgets/practices. Would it be better to remove them, and strictly keep doc...The demos present in the "examples" folder are still stuck on GTK 3, and are becoming increasingly less useful due to demonstrating either deprecated or outdated widgets/practices. Would it be better to remove them, and strictly keep documentation and code for PyGObject itself in this repository?
Any examples present in the "docs" folder would be fine to keep around.https://gitlab.gnome.org/GNOME/pygobject/-/issues/597Gio.Socket.receive API is broken2023-10-10T19:37:43ZMartin Abente LahayeGio.Socket.receive API is broken`Gio.Socket.receive` (and similar) no longer provides a way to access the buffer.
Here's a small snippet to reproduce it:
```bash
# download the snippet below
$ flatpak run --share=network --filesystem=$PWD --command=bash org.gnome.Pla...`Gio.Socket.receive` (and similar) no longer provides a way to access the buffer.
Here's a small snippet to reproduce it:
```bash
# download the snippet below
$ flatpak run --share=network --filesystem=$PWD --command=bash org.gnome.Platform//45
$ python3 snippet.py
```
```python
from gi.repository import Gio, GLib, GObject
class Server(GObject.GObject):
def __init__(self, context):
super().__init__()
self._address = Gio.InetSocketAddress.new_from_string("127.0.0.1", 9999)
self._socket = Gio.Socket.new(Gio.SocketFamily.IPV4, Gio.SocketType.DATAGRAM, Gio.SocketProtocol.UDP)
self._socket.init(None)
self._socket.set_blocking(False)
self._socket.bind(self._address, True)
self._source = self._socket.create_source(GLib.IOCondition.IN, None)
self._source.set_callback(self.__received_data_cb)
self._source.attach(context)
def __received_data_cb(self, source):
size, buffer = self._socket.receive()
print("server", size, buffer.decode("utf_16"))
return True
class Client(GObject.GObject):
def __init__(self):
super().__init__()
self._address = Gio.InetSocketAddress.new_from_string("127.0.0.1", 9999)
self._socket = Gio.Socket.new(Gio.SocketFamily.IPV4, Gio.SocketType.DATAGRAM, Gio.SocketProtocol.UDP)
self._socket.connect(self._address)
def send(self, text):
print("client", self._socket.send(text.encode("utf_16")))
def main():
mainloop = GLib.MainLoop.new(None, True)
context = mainloop.get_context()
server = Server(context)
client = Client()
client.send("foo")
mainloop.run()
if __name__ == "__main__":
main()
```
Errors with:
```
Traceback (most recent call last):
File "/var/home/tchx84/Documents/gnome/snippet.py", line 21, in __received_data_cb
size, buffer = self._socket.receive()
^^^^^^^^^^^^
TypeError: cannot unpack non-iterable int object
```
But, if I changed it to something like `size = self._socket.receive(None)` it "works", but I never get the buffer...https://gitlab.gnome.org/GNOME/pygobject/-/issues/596Objects are leaked when using Template Callbacks or connecting signals2023-10-01T12:34:24ZManuel GenovésObjects are leaked when using Template Callbacks or connecting signalsIf an object is created and a callback defined with the decorator `@Gtk.Template.Callback()` is setup within that object, or even when the callback is connected programatically to a signal, the object won't be disposed until the applicat...If an object is created and a callback defined with the decorator `@Gtk.Template.Callback()` is setup within that object, or even when the callback is connected programatically to a signal, the object won't be disposed until the application closes.
For example (the full reproducer can be found at https://gitlab.gnome.org/somas/leaks_reproducer/):
We spawn window 1. Window 1 has a callback, the handler set up in the UI file and defined using the decorator. We spawn window 2. We close window 1. At this point window 1 has not been freed.
We can see that in the reproducer because window 2 holds a weak reference to window 1, and the callback set up for when the weak reference is dropped is never called. I also added a periodic print for all the referrers of window 1, and the callback function is shown there.https://gitlab.gnome.org/GNOME/pygobject/-/issues/591Rename master git branch to main2024-02-23T13:24:21ZChristoph ReiterRename master git branch to mainMaybe once the next cycle begins.
glib has a todo list here which we could go through: https://gitlab.gnome.org/GNOME/glib/-/issues/2348#note_1104923
Does gitlab have something like github now where branches can be renamed?Maybe once the next cycle begins.
glib has a todo list here which we could go through: https://gitlab.gnome.org/GNOME/glib/-/issues/2348#note_1104923
Does gitlab have something like github now where branches can be renamed?