This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author schmir
Recipients Rebecca, georg.brandl, schmir
Date 2008-01-04.17:19:17
SpamBayes Score 0.0054251556
Marked as misclassified No
Message-id <1199467157.77.0.0764766217247.issue1195@psf.upfronthosting.co.za>
In-reply-to
Content
The following patch fixes it. The end-of-file indicator is still set,
fgets returns NULL when ctrl-c is pressed, and the code checks for
feof(fp) which is true. PyErr_CheckSignals() isn't called.
This patch calls clearerr on the filepointer and consequently after
ctrl-c feof(fp) is false and PyErr_CheckSignals is called.


What I don't understand is why the backtrace says the KeyboardInterrupt
happens in raw_input. PyErr_CheckSignals must be called on the "pass"
statement otherwise something would be fundamentally broken (But I guess
then python somehow saves the last real bytecode command).



~/Python-2.5.1/ hg diff  
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -44,6 +44,7 @@ my_fgets(char *buf, int len, FILE *fp)
                if (PyOS_InputHook != NULL)
                        (void)(PyOS_InputHook)();
                errno = 0;
+               clearerr(fp);
                p = fgets(buf, len, fp);
                if (p != NULL)
                        return 0; /* No error */
History
Date User Action Args
2008-01-04 17:19:18schmirsetspambayes_score: 0.00542516 -> 0.0054251556
recipients: + schmir, georg.brandl, Rebecca
2008-01-04 17:19:17schmirsetspambayes_score: 0.00542516 -> 0.00542516
messageid: <1199467157.77.0.0764766217247.issue1195@psf.upfronthosting.co.za>
2008-01-04 17:19:17schmirlinkissue1195 messages
2008-01-04 17:19:17schmircreate