After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 788890 - Problem when returning an array of enum values
Problem when returning an array of enum values
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2017-10-12 16:18 UTC by Mathieu Duponchelle
Modified: 2017-10-23 08:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
to_py_array: Properly handle enum array items (3.29 KB, patch)
2017-10-22 16:02 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Mathieu Duponchelle 2017-10-12 16:18:35 UTC
I've put up a simple example to reproduce the issue at https://github.com/MathieuDuponchelle/pygobject-enum-array-return , runnable with:

meson build
meson test -C build -v

The introspected function is very simple, it returns an array of two enum values, TEST_FOO and TEST_BAR, in the python program we get [TEST_FOO, TEST_FOO].

If g_new0 isn't used to initialize the array, then we see "invalid enum value: 1701474162"

If the prototype of the function is modified to return an array of gint, we do get [0, 1] as expected.
Comment 1 Christoph Reiter (lazka) 2017-10-13 16:32:46 UTC
Thanks
Comment 2 Christoph Reiter (lazka) 2017-10-22 15:32:32 UTC
Same cause as bug 646581 I think
Comment 3 Christoph Reiter (lazka) 2017-10-22 16:02:07 UTC
Created attachment 362056 [details] [review]
to_py_array: Properly handle enum array items

It used the fallback path and copied pointers.
Do the same thing we do for integer items instead.
Comment 4 Simon Feltman 2017-10-22 23:21:40 UTC
Review of attachment 362056 [details] [review]:

LGTM
Comment 5 Christoph Reiter (lazka) 2017-10-23 08:54:49 UTC
Thanks