]> granicus.if.org Git - python/commitdiff
In a threads-disabled build, typing Ctrl-C into a raw_input() crashed,
authorMichael W. Hudson <mwh@python.net>
Thu, 7 Apr 2005 10:11:19 +0000 (10:11 +0000)
committerMichael W. Hudson <mwh@python.net>
Thu, 7 Apr 2005 10:11:19 +0000 (10:11 +0000)
because (essentially) I didn't realise that PY_BEGIN/END_ALLOW_THREADS
actually expanded to nothing under a no-threads build, so if you somehow
NULLed out the threadstate (e.g. by calling PyThread_SaveThread) it would
stay NULLed when you return to Python.  Argh!

Backport candidate.

Misc/NEWS
Modules/readline.c
Parser/myreadline.c

index fa0b85fee547742b0a26d454f0e6598ea5f667a7..e891cefbb0fbbec0932c470c94277111bd1ac467 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5 alpha 1?
 Core and builtins
 -----------------
 
+- Typing Ctrl-C whilst raw_input() was waiting in a build with threads
+  disabled caused a crash.
+
 - Bug #1165306: instancemethod_new allowed the creation of a method
   with im_class == im_self == NULL, which caused a crash when called.
 
index 7802625611d3b89f07fab6d113c05eb5cedb0669..25a43b2341569b92b69c174ab5d6691465f1a9db 100644 (file)
@@ -775,9 +775,13 @@ readline_until_enter_or_signal(char *prompt, int *signal)
                }
                else if (errno == EINTR) {
                        int s;
+#ifdef WITH_THREAD
                        PyEval_RestoreThread(_PyOS_ReadlineTState);
+#endif
                        s = PyErr_CheckSignals();
+#ifdef WITH_THREAD
                        PyEval_SaveThread();    
+#endif
                        if (s < 0) {
                                rl_free_line_state();
                                rl_cleanup_after_signal();
index 7fc421e9d10a0f6ea991281d815b7477393f01d1..a932a8793aa1d395bd0968fba8564624829f3da1 100644 (file)
@@ -82,9 +82,13 @@ my_fgets(char *buf, int len, FILE *fp)
 #ifdef EINTR
                if (errno == EINTR) {
                        int s;
+#ifdef WITH_THREAD
                        PyEval_RestoreThread(_PyOS_ReadlineTState);
+#endif
                        s = PyErr_CheckSignals();
+#ifdef WITH_THREAD
                        PyEval_SaveThread();
+#endif
                        if (s < 0) {
                                return 1;
                        }