GNOME Bugzilla – Bug 729541
Convert Python bytes to GBytes for input arguments
Last modified: 2018-01-10 20:42:51 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)
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?
(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
Me too. I need that for proper binding of hb_blob_create. See bug 742494. Thanks.
Any chance someone can take a look into this? Thanks :).
(In reply to Behdad Esfahbod from comment #4) > Any chance someone can take a look into this? Thanks :). Anyone? :)
-- 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.