pgi-docgen icon indicating copy to clipboard operation
pgi-docgen copied to clipboard

Some of Gio.InputStream's read methods use byte type buffers, which is an immutable type

Open 0x6d61676e7573 opened this issue 5 years ago • 2 comments

The read_async and read_all_async methods

https://lazka.github.io/pgi-docs/#Gio-2.0/classes/InputStream.html#Gio.InputStream.read_async https://lazka.github.io/pgi-docs/#Gio-2.0/classes/InputStream.html#Gio.InputStream.read_all_async

both take an argument called "buffer" of type bytes. When you click on the hyperlink, you get directed to the documentation on python strings (https://docs.python.org/3/library/stdtypes.html#str), which is not the same type as python bytes. The buffer argument is used by the methods to buffer data, but byte type objects are immutable and therefore should not be written to. I have tried using these methods with byte type buffer, the code runs without warnings, ocassionally works but gives hard-to-detect intermittent errors. I do not know what type one should use here but surely byte must be wrong. Additionally, in the method description, it is not clear what "count" refers to (although one might assume it is the size of the byte object). In the C functions, count appear as arguments to the function, but here they do not.

0x6d61676e7573 avatar Mar 13 '19 19:03 0x6d61676e7573

Yeah, those functions don't work with bindings, the read_bytes_x variants might.

lazka avatar Mar 13 '19 21:03 lazka

Yes, from my (small) experience those versions work.

0x6d61676e7573 avatar Mar 13 '19 22:03 0x6d61676e7573