[Python-checkins] cpython (3.2): Issue #14433: Prevent msvcrt crash in interactive prompt when stdin is closed.

martin.v.loewis python-checkins at python.org
Mon Apr 30 06:28:43 CEST 2012


http://hg.python.org/cpython/rev/2de5e9715fe9
changeset:   76660:2de5e9715fe9
branch:      3.2
parent:      76651:f23222d734bd
user:        Martin v. Löwis <martin at v.loewis.de>
date:        Mon Apr 30 06:10:41 2012 +0200
summary:
  Issue #14433: Prevent msvcrt crash in interactive prompt when stdin is closed.

files:
  Misc/NEWS           |  3 +++
  Parser/myreadline.c |  5 ++++-
  2 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #14433: Prevent msvcrt crash in interactive prompt when stdin
+  is closed.
+
 - Issue #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError
   when repr() or str() is called on such an object.
 
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -42,7 +42,10 @@
             (void)(PyOS_InputHook)();
         errno = 0;
         clearerr(fp);
-        p = fgets(buf, len, fp);
+        if (_PyVerify_fd(fileno(fp)))
+            p = fgets(buf, len, fp);
+        else
+            p = NULL;
         if (p != NULL)
             return 0; /* No error */
         err = errno;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list