Commit 4ae3b447 authored by Victor Stinner's avatar Victor Stinner

(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.
parents a4de6d88 a870e35a
...@@ -10,6 +10,10 @@ What's New in Python 3.3 Alpha 1? ...@@ -10,6 +10,10 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins 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 #9319: Include the filename in "Non-UTF8 code ..." syntax error.
- Issue #10785: Store the filename as Unicode in the Python parser. - Issue #10785: Store the filename as Unicode in the Python parser.
......
...@@ -36,6 +36,7 @@ static int ...@@ -36,6 +36,7 @@ static int
my_fgets(char *buf, int len, FILE *fp) my_fgets(char *buf, int len, FILE *fp)
{ {
char *p; char *p;
while (1) {
if (PyOS_InputHook != NULL) if (PyOS_InputHook != NULL)
(void)(PyOS_InputHook)(); (void)(PyOS_InputHook)();
errno = 0; errno = 0;
...@@ -84,15 +85,18 @@ my_fgets(char *buf, int len, FILE *fp) ...@@ -84,15 +85,18 @@ my_fgets(char *buf, int len, FILE *fp)
#ifdef WITH_THREAD #ifdef WITH_THREAD
PyEval_SaveThread(); PyEval_SaveThread();
#endif #endif
if (s < 0) { if (s < 0)
return 1; return 1;
} /* try again */
continue;
} }
#endif #endif
if (PyOS_InterruptOccurred()) { if (PyOS_InterruptOccurred()) {
return 1; /* Interrupt */ return 1; /* Interrupt */
} }
return -2; /* Error */ return -2; /* Error */
}
/* NOTREACHED */
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment