◐ Shell
clean mode source ↗

Message 201239 - Python tracker

I can't reproduce the access violation on Windows, using Python 2.7.3.

Using the test_bufio.py script by santa4nt, I can see that the fail still happens.

As Santoso Wijaya (santa4nt) said in a previous comment:

The `write(data)` method is getting a `memoryview` object, thus the test code should be using `data.tobytes()` instead of using `bytes(data)`. If we introduce that logic on the test_bufio.py script it passes.

The thing is that if we, instead of doing `import io` (the C version of the module) we do `import _pyio as io` (the pure Python version) the FAIL does not appears at all in the original script!

That difference ("`write` might receive a `memoryview` object if using the C version of this module") is not documented anywhere.

It should, if that's the expected behavior [*], and the code using the io module is responsible for using .tobytes() instead of bytes().

[*] Why "_pyio.py" behaves differently?