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
mywrite() ignores PyFile_WriteString() errors #52371
Comments
PyFile_WriteString() calls PyObject_Str() which calls PyErr_CheckSignals(). If a signal was catched, the signal handler is called. If the signal handler raises an error, PyObject_Str() and then PyFile_WriteString() return NULL. mywrite() ignores all PyFile_WriteString() errors. It should maybe only ignores errors from the file (except IOError: ...) and not any error. Another problem: mywrite() is called from PySys_WriteStdout() and PySys_WriteStderr() which are procedures. PySys_WriteStdout()/PySys_WriteStderr() caller cannot detect the error. There are 65 calls to PySys_WriteStd... |
This bug is related to bpo-3137. |
Another solution: disable call to PyErr_CheckSignals() in mywrite(). |
Attached patch fixes this issue: PyFile_WriteObject() doesn't call PyObject_Str() to avoid PyErr_CheckSignals(). I'm not sure that it's the right approch because it may change the behaviour of existing code when getting a signal. |
Ok, forget my pyfile_writeobject_nosignal.patch, it's not the right approach. New patch: mywrite() uses its own implementation PyFile_WriteString(), sys_pyfile_write(), which doesn't call PyErr_CheckSignals(): /* Implementation of PyFile_WriteString() no calling PyErr_CheckSignals():
|
The goal is this issue is also to catch SIGINT when starting Python. It now works in Python trunk and py3k, but not in verbose mode because mywrite() eats errors (especially the KeyboardInterrupt raised by the default SIGINT handler) and calls indirectly Python signal handlers. |
Commited: r80404 (py3k), r80405 (3.1). |
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: