Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99ec7f6

Browse files
committed
Additional fix for issue #12268: The io module file object write methods no
longer abort early when a write system call is interrupted (EINTR).
2 parents 193e1be + b9817b0 commit 99ec7f6

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ Library
506506
- Issue #15906: Fix a regression in `argparse` caused by the preceding change,
507507
when ``action='append'``, ``type='str'`` and ``default=[]``.
508508

509+
Extension Modules
510+
-----------------
511+
512+
- Issue #12268: The io module file object write methods no longer abort early
513+
when one of its write system calls is interrupted (EINTR).
514+
509515
Tests
510516
-----
511517

Modules/_io/iobase.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,10 @@ iobase_writelines(PyObject *self, PyObject *args)
669669
break; /* Stop Iteration */
670670
}
671671

672-
res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL);
672+
res = NULL;
673+
do {
674+
res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL);
675+
} while (res == NULL && _PyIO_trap_eintr());
673676
Py_DECREF(line);
674677
if (res == NULL) {
675678
Py_DECREF(iter);

Modules/_io/textio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,8 +1247,11 @@ _textiowrapper_writeflush(textio *self)
12471247
Py_DECREF(pending);
12481248
if (b == NULL)
12491249
return -1;
1250-
ret = PyObject_CallMethodObjArgs(self->buffer,
1251-
_PyIO_str_write, b, NULL);
1250+
ret = NULL;
1251+
do {
1252+
ret = PyObject_CallMethodObjArgs(self->buffer,
1253+
_PyIO_str_write, b, NULL);
1254+
} while (ret == NULL && _PyIO_trap_eintr());
12521255
Py_DECREF(b);
12531256
if (ret == NULL)
12541257
return -1;

0 commit comments

Comments
 (0)