]> granicus.if.org Git - python/commitdiff
Issue #14433: Prevent msvcrt crash in interactive prompt when stdin is closed.
authorMartin v. Löwis <martin@v.loewis.de>
Mon, 30 Apr 2012 04:10:41 +0000 (06:10 +0200)
committerMartin v. Löwis <martin@v.loewis.de>
Mon, 30 Apr 2012 04:10:41 +0000 (06:10 +0200)
Misc/NEWS
Parser/myreadline.c

index 53aa0745f2c51b292045092e71e9d0673a789d41..3b896d151c56e2253e6ce739971cea5643669188 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2.4
 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.
 
index 33d5b3d4cc402cd4e105d99b472d874fffd038fd..cb1cf0f56d7d24394adbd7aec8e5facf5b3e5f96 100644 (file)
@@ -42,7 +42,10 @@ my_fgets(char *buf, int len, FILE *fp)
             (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;