]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Additional fix for Issue #12268: The io module file object writelines() methods
authorGregory P. Smith <greg@krypto.org>
Fri, 1 Feb 2013 21:02:59 +0000 (13:02 -0800)
committerGregory P. Smith <greg@krypto.org>
Fri, 1 Feb 2013 21:02:59 +0000 (13:02 -0800)
no longer abort early when one of its write system calls is interrupted (EINTR).

Misc/NEWS
Modules/_io/iobase.c
Modules/_io/textio.c

index 2d46d7d75f9fa10e4fbcfb46ef03bb72534018c5..b74b2f64d44be5f4c49eb44c148990248d517ba6 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -679,6 +679,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 04caea4cb6e4f50cb3ed526a1c4dfa2afce4ff09..063ba2ebd83c4f42e47b32836ecf9b0ee200dbd2 100644 (file)
@@ -660,7 +660,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 d2e92fa20170ca738cb60558250159217a63d873..c9913d4a9eb9765b2df316f9d7857ff17a142aaa 100644 (file)
@@ -1213,8 +1213,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;