diff -r 70274d53c1dd Modules/readline.c --- a/Modules/readline.c Mon Apr 09 19:04:04 2012 -0400 +++ b/Modules/readline.c Fri Oct 26 14:22:47 2012 +0200 @@ -709,7 +709,7 @@ if (func != NULL) { PyObject *r; #ifdef WITH_THREAD - PyGILState_STATE gilstate = PyGILState_Ensure(); + PyEval_RestoreThread(_PyOS_ReadlineTState); #endif r = PyObject_CallFunction(func, NULL); if (r == NULL) @@ -728,7 +728,7 @@ Py_XDECREF(r); done: #ifdef WITH_THREAD - PyGILState_Release(gilstate); + PyEval_SaveThread(); #endif return result; } @@ -759,7 +759,7 @@ int i; PyObject *m=NULL, *s=NULL, *r=NULL; #ifdef WITH_THREAD - PyGILState_STATE gilstate = PyGILState_Ensure(); + PyEval_RestoreThread(_PyOS_ReadlineTState); #endif m = PyList_New(num_matches); if (m == NULL) @@ -790,7 +790,7 @@ Py_XDECREF(r); } #ifdef WITH_THREAD - PyGILState_Release(gilstate); + PyEval_SaveThread(); #endif } @@ -804,7 +804,7 @@ if (completer != NULL) { PyObject *r; #ifdef WITH_THREAD - PyGILState_STATE gilstate = PyGILState_Ensure(); + PyEval_RestoreThread(_PyOS_ReadlineTState); #endif rl_attempted_completion_over = 1; r = PyObject_CallFunction(completer, "si", text, state); @@ -826,7 +826,7 @@ Py_XDECREF(r); done: #ifdef WITH_THREAD - PyGILState_Release(gilstate); + PyEval_SaveThread(); #endif return result; }