From b9817b01edfe6fa369c4c291a5de00732b8abc7c Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Fri, 1 Feb 2013 13:03:39 -0800 Subject: Additional fix for Issue #12268: The io module file object writelines() methods no longer abort early when one of its write system calls is interrupted (EINTR). --- Misc/NEWS | 3 +++ Modules/_io/iobase.c | 5 ++++- Modules/_io/textio.c | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index 917ab8d..4431f18 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -817,6 +817,9 @@ Library Extension Modules ----------------- +- Issue #12268: The io module file object writelines() methods no longer + abort early when one of its write system calls is interrupted (EINTR). + - Fix the leak of a dict in the time module when used in an embedded interpreter that is repeatedly initialized and shutdown and reinitialized. diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index ba86146..8b17ecd 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -674,7 +674,10 @@ iobase_writelines(PyObject *self, PyObject *args) break; /* Stop Iteration */ } - res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL); + res = NULL; + do { + res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL); + } while (res == NULL && _PyIO_trap_eintr()); Py_DECREF(line); if (res == NULL) { Py_DECREF(iter); diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 2fbb8f3..7d48388 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1249,8 +1249,11 @@ _textiowrapper_writeflush(textio *self) Py_DECREF(pending); if (b == NULL) return -1; - ret = PyObject_CallMethodObjArgs(self->buffer, - _PyIO_str_write, b, NULL); + ret = NULL; + do { + ret = PyObject_CallMethodObjArgs(self->buffer, + _PyIO_str_write, b, NULL); + } while (ret == NULL && _PyIO_trap_eintr()); Py_DECREF(b); if (ret == NULL) return -1; -- cgit v0.12