← 输入框|bugs.python.org|刷新

➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: mywrite() ignores PyFile_WriteString() errors
类型: behavior Stage:
Components: Interpreter Core Versions: Python 3.1, Python 3.2
process
状态: closed Resolution: fixed
Dependencies: 后续:
分配给: 抄送列表: vstinner
优先级: normal 关键字: patch

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

文件
文件名 上传时间 Description 编辑
mywrite_nosignal.patch vstinner, 2010-04-22 11:11
Messages (7)
msg100939 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 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) 日期: 2010-03-12 16:10
This bug is related to #3137.
msg103711 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2010-04-20 14:11
Another solution: disable call to PyErr_CheckSignals() in mywrite().
msg103946 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 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) 日期: 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) 日期: 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) 日期: 2010-04-23 12:05
Commited: r80404 (py3k), r80405 (3.1).
历史
日期 用户 动作 参数
2022-04-11 14:56:58admin修改github: 52371
2010-04-23 12:05:11vstinner修改状态: open -> closed
resolution: fixed
消息: + msg104006
2010-04-22 11:14:44vstinner修改消息: + msg103949
2010-04-22 11:12:02vstinner修改文件: - pyfile_writeobject_nosignal.patch
2010-04-22 11:11:42vstinner修改文件: + mywrite_nosignal.patch

消息: + msg103948
2010-04-22 10:59:20vstinner修改文件: + pyfile_writeobject_nosignal.patch
keywords: + patch
消息: + msg103946
2010-04-20 14:11:02vstinner修改消息: + msg103711
2010-03-12 16:10:28vstinner修改消息: + msg100942
2010-03-12 16:08:37vstinner创建