]> granicus.if.org Git - python/commitdiff
Additional fix for Issue #12268: The io module file object writelines() methods no...
authorGregory P. Smith <greg@krypto.org>
Fri, 1 Feb 2013 21:03:39 +0000 (13:03 -0800)
committerGregory P. Smith <greg@krypto.org>
Fri, 1 Feb 2013 21:03:39 +0000 (13:03 -0800)
Misc/NEWS
Modules/_io/iobase.c
Modules/_io/textio.c

index 917ab8d062667006ac9360dfbaf3911005b10d8d..4431f1878cd926da55a6737ba72b5127a7bd04d8 100644 (file)
--- 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.
 
index ba861467904e2f25972071166e3888b2457efcf6..8b17ecdd8561e457b3be12a0143e03b9082384e7 100644 (file)
@@ -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);
index 2fbb8f3052350ad00a2b0e1cf552a19c8f9df2a1..7d48388493172fc194d013675b34098301afe1c7 100644 (file)
@@ -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;