summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-12-16 11:29:37 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-12-16 11:29:37 (GMT)
commitab0e9f7089c04df546af6cacbc8751247cf4020a (patch)
tree3494351a976a17a62146a3ddd365fe2b5936fca4 /Parser
parente2b2bf55b30299e310b246b5b4b6f5a5f66e75b2 (diff)
parentc345ce1a69b3c4a46d87ef56d859bc70abfc74b4 (diff)
downloadcpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.zip
cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.tar.gz
cpython-ab0e9f7089c04df546af6cacbc8751247cf4020a.tar.bz2
Issue #10350: Read and save errno before calling a function which might overwrite it.
Original patch by Hallvard B Furuseth.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/myreadline.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index fb4b805..33d5b3d 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -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);