mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #10350: Read and save errno before calling a function which might overwrite it.
Original patch by Hallvard B Furuseth.
This commit is contained in:
parent
87448819ab
commit
c345ce1a69
7 changed files with 33 additions and 12 deletions
|
@ -36,6 +36,7 @@ static int
|
|||
my_fgets(char *buf, int len, FILE *fp)
|
||||
{
|
||||
char *p;
|
||||
int err;
|
||||
while (1) {
|
||||
if (PyOS_InputHook != NULL)
|
||||
(void)(PyOS_InputHook)();
|
||||
|
@ -44,6 +45,7 @@ my_fgets(char *buf, int len, FILE *fp)
|
|||
p = fgets(buf, len, fp);
|
||||
if (p != NULL)
|
||||
return 0; /* No error */
|
||||
err = errno;
|
||||
#ifdef MS_WINDOWS
|
||||
/* In the case of a Ctrl+C or some other external event
|
||||
interrupting the operation:
|
||||
|
@ -78,7 +80,7 @@ my_fgets(char *buf, int len, FILE *fp)
|
|||
return -1; /* EOF */
|
||||
}
|
||||
#ifdef EINTR
|
||||
if (errno == EINTR) {
|
||||
if (err == EINTR) {
|
||||
int s;
|
||||
#ifdef WITH_THREAD
|
||||
PyEval_RestoreThread(_PyOS_ReadlineTState);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue