From: Martin v. Löwis Date: Mon, 30 Apr 2012 04:10:41 +0000 (+0200) Subject: Issue #14433: Prevent msvcrt crash in interactive prompt when stdin is closed. X-Git-Tag: v3.3.0a3~21^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e654c11f565d1be32062931dc0a1817004b7387b;p=thirdparty%2FPython%2Fcpython.git Issue #14433: Prevent msvcrt crash in interactive prompt when stdin is closed. --- diff --git a/Misc/NEWS b/Misc/NEWS index 53aa0745f2c5..3b896d151c56 100644 --- 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. diff --git a/Parser/myreadline.c b/Parser/myreadline.c index 33d5b3d4cc40..cb1cf0f56d7d 100644 --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -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;