Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
0x6d61676e7573 opened this issue Mar 13, 2019 · 2 comments

Comments

@0x6d61676e7573
Copy link

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.

@lazka
Copy link
Member

lazka commented Mar 13, 2019

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

@0x6d61676e7573
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants