Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e654c11

Browse files
committed
Issue #14433: Prevent msvcrt crash in interactive prompt when stdin is closed.
1 parent b8f02b5 commit e654c11

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.2.4
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #14433: Prevent msvcrt crash in interactive prompt when stdin
14+
is closed.
15+
1316
- Issue #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError
1417
when repr() or str() is called on such an object.
1518

Parser/myreadline.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ my_fgets(char *buf, int len, FILE *fp)
4242
(void)(PyOS_InputHook)();
4343
errno = 0;
4444
clearerr(fp);
45-
p = fgets(buf, len, fp);
45+
if (_PyVerify_fd(fileno(fp)))
46+
p = fgets(buf, len, fp);
47+
else
48+
p = NULL;
4649
if (p != NULL)
4750
return 0; /* No error */
4851
err = errno;

0 commit comments

Comments
 (0)