Ralf Schmitt added the comment:

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 */

----------
nosy: +schmir

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1195>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to