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 729541 - Convert Python bytes to GBytes for input arguments
Convert Python bytes to GBytes for input arguments
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-04 22:32 UTC by Simon Feltman
Modified: 2018-01-10 20:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Simon Feltman 2014-05-04 22:32:05 UTC
Methods which take GBytes as arguments should allow automatic conversion from Python bytes objects (or really anything that implements the Python buffer protocol).

Currently a GBytes object needs manual construction. I assume this is also the case for GByteArray.

>>> from gi.repository import GLib, Gio
>>> inbytes = GLib.Bytes.new_take(b'asdf')
>>> stream = Gio.MemoryInputStream.new_from_bytes(inbytes)
Comment 1 John Stowers 2014-05-08 12:03:08 UTC
I've kind of got a need for this (specifically, taking data from objects implementing the buffer protocol).

In that case I assume the integration must be done in C.

Do you have any pointers or examples in the current codebase of integrating code in this way so I make start to hack on this?
Comment 2 Simon Feltman 2014-05-08 17:05:45 UTC
(In reply to comment #1)
> Do you have any pointers or examples in the current codebase of integrating
> code in this way so I make start to hack on this?

Here's a brain dump, tutorial style:
https://wiki.gnome.org/Projects/PyGObject/GBytesMarshalerTutorial
Comment 3 Behdad Esfahbod 2015-01-07 01:49:26 UTC
Me too.  I need that for proper binding of hb_blob_create.  See bug 742494.  Thanks.
Comment 4 Behdad Esfahbod 2016-01-21 13:20:33 UTC
Any chance someone can take a look into this?  Thanks :).
Comment 5 Behdad Esfahbod 2017-04-05 12:31:30 UTC
(In reply to Behdad Esfahbod from comment #4)
> Any chance someone can take a look into this?  Thanks :).

Anyone? :)
Comment 6 GNOME Infrastructure Team 2018-01-10 20:42:51 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/71.