(Merge 3.1) 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.
This commit is contained in:
Victor Stinner 2011-04-09 15:59:25 +02:00
commit a870e35a7d
2 changed files with 59 additions and 51 deletions

View File

@ -10,6 +10,10 @@ What's New in Python 3.2.1?
Core and Builtins
-----------------
- 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.
- Issue #11395: io.FileIO().write() clamps the data length to 32,767 bytes on
Windows if the file is a TTY to workaround a Windows bug. The Windows console
returns an error (12: not enough space error) on writing into stdout if

View File

@ -36,6 +36,7 @@ static int
my_fgets(char *buf, int len, FILE *fp)
{
char *p;
while (1) {
if (PyOS_InputHook != NULL)
(void)(PyOS_InputHook)();
errno = 0;
@ -84,9 +85,10 @@ my_fgets(char *buf, int len, FILE *fp)
#ifdef WITH_THREAD
PyEval_SaveThread();
#endif
if (s < 0) {
if (s < 0)
return 1;
}
/* try again */
continue;
}
#endif
if (PyOS_InterruptOccurred()) {
@ -94,6 +96,8 @@ my_fgets(char *buf, int len, FILE *fp)
}
return -2; /* Error */
}
/* NOTREACHED */
}
/* Readline implementation using fgets() */