Index: Parser/myreadline.c =================================================================== --- Parser/myreadline.c (revision 79993) +++ Parser/myreadline.c (working copy) @@ -44,8 +44,12 @@ (void)(PyOS_InputHook)(); errno = 0; p = fgets(buf, len, fp); - if (p != NULL) + if (p != NULL) { + if (feof(fp)) { + return -1; /* EOF, but some characters have been read. */ + } return 0; /* No error */ + } #ifdef MS_WINDOWS /* In the case of a Ctrl+C or some other external event interrupting the operation: @@ -76,7 +80,7 @@ } #endif /* MS_WINDOWS */ if (feof(fp)) { - return -1; /* EOF */ + return -1; /* EOF, no characters have been read. */ } #ifdef EINTR if (errno == EINTR) {