summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-30 21:46:00 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-30 21:46:00 (GMT)
commit4f71101eeda6fb0b55805ebcb12d11124ab3b567 (patch)
tree67e214541a944009850bc0997a507be17a20ed6a
parent76450a96efb6ea60187c358edef218ef71a18ed9 (diff)
downloadcpython-4f71101eeda6fb0b55805ebcb12d11124ab3b567.zip
cpython-4f71101eeda6fb0b55805ebcb12d11124ab3b567.tar.gz
cpython-4f71101eeda6fb0b55805ebcb12d11124ab3b567.tar.bz2
Issue #12016: my_fgets() now always clears errors before calling fgets(). Fix
the following case: sys.stdin.read() stopped with CTRL+d (end of file), raw_input() interrupted by CTRL+c.
-rw-r--r--Misc/NEWS4
-rw-r--r--Parser/myreadline.c1
2 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index e9bfef9..17ba290 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,10 @@ What's New in Python 3.2.1 release candidate 2?
Core and Builtins
-----------------
+- Issue #12016: my_fgets() now always clears errors before calling fgets(). Fix
+ the following case: sys.stdin.read() stopped with CTRL+d (end of file),
+ raw_input() interrupted by CTRL+c.
+
- Issue #9670: Increase the default stack size for secondary threads on
Mac OS X and FreeBSD to reduce the chances of a crash instead of a
"maximum recursion depth" RuntimeError exception.
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index b12d052..fb4b805 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -40,6 +40,7 @@ my_fgets(char *buf, int len, FILE *fp)
if (PyOS_InputHook != NULL)
(void)(PyOS_InputHook)();
errno = 0;
+ clearerr(fp);
p = fgets(buf, len, fp);
if (p != NULL)
return 0; /* No error */