summaryrefslogtreecommitdiffstats
path: root/Modules/readline.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-10-10 17:39:19 (GMT)
committerGuido van Rossum <guido@python.org>1997-10-10 17:39:19 (GMT)
commita59406abdfd1393db708b379003fe3ab0dd0af2e (patch)
tree4d15e01e6ca96c7b9a27955b0a3e2384465007ce /Modules/readline.c
parent04d5c5827af1819d0b114655a3c5359bdd42a4a7 (diff)
downloadcpython-a59406abdfd1393db708b379003fe3ab0dd0af2e.zip
cpython-a59406abdfd1393db708b379003fe3ab0dd0af2e.tar.gz
cpython-a59406abdfd1393db708b379003fe3ab0dd0af2e.tar.bz2
Darn. When thread support is disabled, the BEGIN/END macros don't
save and restore the tstate, but explicitly calling PyEval_SaveThread() does reset it! While I think about how to fix this for real, here's a fix that avoids getting a fatal error.
Diffstat (limited to 'Modules/readline.c')
-rw-r--r--Modules/readline.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index 1231e03..e12ae1d 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -168,8 +168,10 @@ on_completion(text, state)
char *result = NULL;
if (completer != NULL) {
PyObject *r;
+ PyThreadState *save_tstate;
/* Note that readline is called with the interpreter
lock released! */
+ save_tstate = PyThreadState_Swap(NULL);
PyEval_RestoreThread(tstate);
r = PyObject_CallFunction(completer, "si", text, state);
if (r == NULL)
@@ -190,6 +192,7 @@ on_completion(text, state)
Py_XDECREF(r);
done:
PyEval_SaveThread();
+ PyThreadState_Swap(save_tstate);
}
return result;
}