diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2021-03-30 07:54:42 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2021-03-30 08:31:16 +0200 |
commit | c45eec02185b425e353f5fc477b04567d9627fcb (patch) | |
tree | d5219203c62ed450fa629900cbb98eae87457892 /gi | |
parent | 6c17628365abfcd7d5868f6f812390380c0ad1ec (diff) | |
download | pygobject-c45eec02185b425e353f5fc477b04567d9627fcb.tar.gz |
Fix regression in marshalling partial() objects
In a4880dbc4575fadc0e3 a special case for partial() was added to handle gtk4 template
callbacks. This in turn broken normal usage of partial objects.
To work around that add a special marker in the gtk template code for now until
we find a better fix.
Also adds a test so this doesn't happen again.
Fixes #464
Diffstat (limited to 'gi')
-rw-r--r-- | gi/_gtktemplate.py | 7 | ||||
-rw-r--r-- | gi/pygi-struct-marshal.c | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/gi/_gtktemplate.py b/gi/_gtktemplate.py index a631a6eb..925aa0dd 100644 --- a/gi/_gtktemplate.py +++ b/gi/_gtktemplate.py @@ -78,9 +78,12 @@ def define_builder_scope(): handler, args = _extract_handler_and_args(current_object, handler_name) if obj: - return partial(handler, *args, swap_data=obj) + p = partial(handler, *args, swap_data=obj) + else: + p = partial(handler, *args) - return partial(handler, *args) + p.__gtk_template__ = True + return p return BuilderScope diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c index 0e190b8e..a3eb2802 100644 --- a/gi/pygi-struct-marshal.c +++ b/gi/pygi-struct-marshal.c @@ -191,7 +191,7 @@ pygi_arg_gclosure_from_py_marshal (PyObject *py_arg, Py_DECREF (functools); } - if (partial && PyObject_IsInstance (py_arg, partial) > 0) { + if (partial && PyObject_IsInstance (py_arg, partial) > 0 && PyObject_HasAttrString (py_arg, "__gtk_template__")) { PyObject *partial_func; PyObject *partial_args; PyObject *partial_keywords; |