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 761101 - Union type not working correctly with python 3 and GObject introspection
Union type not working correctly with python 3 and GObject introspection
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
3.18.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-25 18:38 UTC by Vratislav Podzimek
Modified: 2018-01-10 20:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the reproducer sources (1.67 KB, application/gzip)
2016-01-25 18:38 UTC, Vratislav Podzimek
Details

Description Vratislav Podzimek 2016-01-25 18:38:36 UTC
Created attachment 319698 [details]
the reproducer sources

Description of problem:
If I have a union type in my GObject-based code and try to use it from python 3, the right value doesn't get to the "C side". However, this works just fine with python 2. Running the attached reproducer I get this:

$ GI_TYPELIB_PATH=. LD_LIBRARY_PATH=. python reproducer.py 
got unit with int value: 1
got unit with int value: 2
got unit with int value: 3

$ GI_TYPELIB_PATH=. LD_LIBRARY_PATH=. python3 reproducer.py 
got unit with int value: 1
got unit with int value: 1
got unit with int value: 1

How reproducible:
100%

Steps to Reproduce:
1. unpack the attached reproducer
2. run rebuild_test_data.sh
3. run $ GI_TYPELIB_PATH=. LD_LIBRARY_PATH=. python reproducer.py
4. run $ GI_TYPELIB_PATH=. LD_LIBRARY_PATH=. python3 reproducer.py

Actual results:
different behaviour for python 2 (correct) and python 3 (wrong)

Expected results:
the same (correct) behaviour in python 3 as in python 2

Additional info:
this blocks python-blivet [1] from starting to use the new libbytesize library [2]

[1] https://github.com/rhinstaller/blivet
[2] https://github.com/rhinstaller/libbytesize
Comment 1 Christoph Reiter (lazka) 2017-04-03 08:25:04 UTC
Looks like enum access in unions isn't implemented at all and this just works by chance with Python 2.
Comment 2 GNOME Infrastructure Team 2018-01-10 20:52:41 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/109.