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

Skip to content

Commit 52c950f

Browse files
author
Victor Stinner
committed
Issue #11650: PyOS_StdioReadline() retries fgets() if it was interrupted
(EINTR), for example if the program is stopped with CTRL+z on Mac OS X. Patch written by Charles-Francois Natali.
1 parent e1292a2 commit 52c950f

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ What's New in Python 3.1.4?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #11650: PyOS_StdioReadline() retries fgets() if it was interrupted
14+
(EINTR), for example if the program is stopped with CTRL+z on Mac OS X. Patch
15+
written by Charles-Francois Natali.
16+
1317
- Issue #8651: PyArg_Parse*() functions raise an OverflowError if the file
1418
doesn't have PY_SSIZE_T_CLEAN define and the size doesn't fit in an int
1519
(length bigger than 2^31-1 bytes).

Parser/myreadline.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static int
3636
my_fgets(char *buf, int len, FILE *fp)
3737
{
3838
char *p;
39-
for (;;) {
39+
while (1) {
4040
if (PyOS_InputHook != NULL)
4141
(void)(PyOS_InputHook)();
4242
errno = 0;
@@ -85,9 +85,10 @@ my_fgets(char *buf, int len, FILE *fp)
8585
#ifdef WITH_THREAD
8686
PyEval_SaveThread();
8787
#endif
88-
if (s < 0) {
89-
return 1;
90-
}
88+
if (s < 0)
89+
return 1;
90+
/* try again */
91+
continue;
9192
}
9293
#endif
9394
if (PyOS_InterruptOccurred()) {

0 commit comments

Comments
 (0)