(Merge 3.2) 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 16:01:55 +02:00
commit 4ae3b447c8
2 changed files with 59 additions and 51 deletions

View File

@ -10,6 +10,10 @@ What's New in Python 3.3 Alpha 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 #9319: Include the filename in "Non-UTF8 code ..." syntax error.
- Issue #10785: Store the filename as Unicode in the Python parser.

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,15 +85,18 @@ 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()) {
return 1; /* Interrupt */
}
return -2; /* Error */
}
/* NOTREACHED */
}