[Python-checkins] python/dist/src/Modules readline.c,2.41.6.3,2.41.6.4

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 07 Jan 2003 12:38:03 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv24999

Modified Files:
      Tag: release22-maint
	readline.c 
Log Message:
Backport 2.58 from trunk (minus the cleanup):

Fix from Michael Stone for SF bug #660476 and #513033 (bogus thread
state swaps in readline).


Index: readline.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v
retrieving revision 2.41.6.3
retrieving revision 2.41.6.4
diff -C2 -d -r2.41.6.3 -r2.41.6.4
*** readline.c	6 Oct 2002 05:43:47 -0000	2.41.6.3
--- readline.c	7 Jan 2003 20:37:58 -0000	2.41.6.4
***************
*** 405,418 ****
  
  static int
! on_hook(PyObject *func, PyThreadState *tstate)
  {
  	int result = 0;
  	if (func != 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(func, NULL);
  		if (r == NULL)
--- 405,416 ----
  
  static int
! on_hook(PyObject *func, PyThreadState **tstate)
  {
  	int result = 0;
  	if (func != NULL) {
  		PyObject *r;
  		/* Note that readline is called with the interpreter
  		   lock released! */
! 		PyEval_RestoreThread(*tstate);
  		r = PyObject_CallFunction(func, NULL);
  		if (r == NULL)
***************
*** 428,433 ****
  		Py_XDECREF(r);
  	  done:
! 		PyEval_SaveThread();
! 		PyThreadState_Swap(save_tstate);
  	}
  	return result;
--- 426,430 ----
  		Py_XDECREF(r);
  	  done:
! 		*tstate = PyEval_SaveThread();
  	}
  	return result;
***************
*** 437,441 ****
  on_startup_hook(void)
  {
! 	return on_hook(startup_hook, startup_hook_tstate);
  }
  
--- 434,438 ----
  on_startup_hook(void)
  {
! 	return on_hook(startup_hook, &startup_hook_tstate);
  }
  
***************
*** 444,448 ****
  on_pre_input_hook(void)
  {
! 	return on_hook(pre_input_hook, pre_input_hook_tstate);
  }
  #endif
--- 441,445 ----
  on_pre_input_hook(void)
  {
! 	return on_hook(pre_input_hook, &pre_input_hook_tstate);
  }
  #endif
***************
*** 456,463 ****
  	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(completer_tstate);
  		r = PyObject_CallFunction(completer, "si", text, state);
--- 453,458 ----
***************
*** 479,484 ****
  		Py_XDECREF(r);
  	  done:
! 		PyEval_SaveThread();
! 		PyThreadState_Swap(save_tstate);
  	}
  	return result;
--- 474,478 ----
  		Py_XDECREF(r);
  	  done:
! 		completer_tstate = PyEval_SaveThread();
  	}
  	return result;