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
PEP 475: Add _Py_read() and _Py_write() functions #67896
Comments
To factorize code handling EINTR, I propose add 2 new functions to fileutils.h: _Py_read() and _Py_write(). Attached patch adds these functions and use them in the os and _io modules. The code of the functions is based on the code from the os and _io modules. The main change is that the functions now truncate code if greater than PY_SSIZE_T_MAX. Other changes are just refactoring. |
select_write.patch: use _Py_write() in the select module. |
I created the issue bpo-23709 for the ossaudiodev module: "Refactor ossaudiodev: use _Py_read and _Py_write with the Py_buffer". |
With py_read_write.patch in debug mode, test_threading crash with an assertion error because of the issue bpo-15751. Currently, it's not possible to call assert(PyGILState_Check()); inside Py_NewInterpreter(), while creating a subinterpreter (ex: _testcapi.run_in_subinterp()). The workaround is to comment the assertion in _Py_read() and Py_write() until the issue bpo-15751 is fixed. |
Oops, there was a bug in FileIO.readall(), fixed in the new patch py_read_write-2.patch. I also commented assert(PyGILState_Check()); to workaround the issue bpo-15751. |
New changeset c3c47ea32f72 by Victor Stinner in branch 'default': |
New changeset e232b57ee784 by Victor Stinner in branch 'default': |
I commited both patches. Thanks Antoine for the review of py_read_write-2.patch, I removed the commented assertion. |
New changeset 116e4c40115f by Victor Stinner in branch 'default': |
An assertion failed in _Py_read() while running test_signal on AMD64 Snow Leop 3.x: http://buildbot.python.org/all/builders/AMD64%20Snow%20Leop%203.x/builds/2779/steps/test/logs/stdio [321/393/1] test_signal Current thread 0x00007fff71296cc0 (most recent call first): |
New changeset 6dd201b6bb4f by Victor Stinner in branch 'default': |
Same error on "x86 Tiger 3.x" buildbot: http://buildbot.python.org/all/builders/x86%20Tiger%203.x/builds/9381/steps/test/logs/stdio [345/393] test_signal Current thread 0xa000d000 (most recent call first): |
New changeset 07fd54208434 by Victor Stinner in branch 'default': |
When I wrote _Py_read()/_Py_write(), I added assertions on errno to ensure that errno is not modified. I chose to use assertions instead of save/restore errno because on Linux errno is not modified. Since they *are* platforms where errno is modified, it's safer to always save/restore errno. _Py_read()/_Py_write() *must* set set errno because some callers uses it. It's more convinient to use errno than having to get the errno attribute of the raised OSError exception. test_signal pass again on "AMD64 Snow Leop 3.x" buildbot, I close the issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: