Issue 8124: mywrite() ignores PyFile_WriteString() errors (original) (raw)

Created on 2010-03-12 16:08 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mywrite_nosignal.patch vstinner,2010-04-22 11:11
Messages (7)
msg100939 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-03-12 16:08
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...
msg100942 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-03-12 16:10
This bug is related to #3137.
msg103711 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-20 14:11
Another solution: disable call to PyErr_CheckSignals() in mywrite().
msg103946 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-22 10:59
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.
msg103948 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-22 11:11
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(): * mywrite() should not execute any Python signal handler to avoid raising an * error because mywrite() ignores all errors */
msg103949 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-22 11:14
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.
msg104006 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-04-23 12:05
Commited: r80404 (py3k), r80405 (3.1).
History
Date User Action Args
2022-04-11 14:56:58 admin set github: 52371
2010-04-23 12:05:11 vstinner set status: open -> closedresolution: fixedmessages: +
2010-04-22 11:14:44 vstinner set messages: +
2010-04-22 11:12:02 vstinner set files: - pyfile_writeobject_nosignal.patch
2010-04-22 11:11:42 vstinner set files: + mywrite_nosignal.patchmessages: +
2010-04-22 10:59:20 vstinner set files: + pyfile_writeobject_nosignal.patchkeywords: + patchmessages: +
2010-04-20 14:11:02 vstinner set messages: +
2010-03-12 16:10:28 vstinner set messages: +
2010-03-12 16:08:37 vstinner create