[Python-checkins] cpython (3.2): Additional fix for Issue #12268: The io module file object writelines() methods

gregory.p.smith python-checkins at python.org
Fri Feb 1 22:12:27 CET 2013


http://hg.python.org/cpython/rev/2fd669aa4abc
changeset:   81876:2fd669aa4abc
branch:      3.2
parent:      81871:0c5fa35c9f12
user:        Gregory P. Smith <greg at krypto.org>
date:        Fri Feb 01 13:03:39 2013 -0800
summary:
  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).

files:
  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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -817,6 +817,9 @@
 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
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -674,7 +674,10 @@
                 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
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1249,8 +1249,11 @@
     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;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list