@@ -154,6 +154,7 @@ write_history_file(PyObject *self, PyObject *args)
154154{
155155 PyObject * filename_obj = Py_None , * filename_bytes ;
156156 char * filename ;
157+ int err ;
157158 if (!PyArg_ParseTuple (args , "|O:write_history_file" , & filename_obj ))
158159 return NULL ;
159160 if (filename_obj != Py_None ) {
@@ -164,10 +165,11 @@ write_history_file(PyObject *self, PyObject *args)
164165 filename_bytes = NULL ;
165166 filename = NULL ;
166167 }
167- errno = write_history (filename );
168- if (!errno && _history_length >= 0 )
168+ errno = err = write_history (filename );
169+ if (!err && _history_length >= 0 )
169170 history_truncate_file (filename , _history_length );
170171 Py_XDECREF (filename_bytes );
172+ errno = err ;
171173 if (errno )
172174 return PyErr_SetFromErrno (PyExc_IOError );
173175 Py_RETURN_NONE ;
@@ -969,7 +971,7 @@ readline_until_enter_or_signal(char *prompt, int *signal)
969971 completed_input_string = not_done_reading ;
970972
971973 while (completed_input_string == not_done_reading ) {
972- int has_input = 0 ;
974+ int has_input = 0 , err = 0 ;
973975
974976 while (!has_input )
975977 { struct timeval timeout = {0 , 100000 }; /* 0.1 seconds */
@@ -983,13 +985,14 @@ readline_until_enter_or_signal(char *prompt, int *signal)
983985 /* select resets selectset if no input was available */
984986 has_input = select (fileno (rl_instream ) + 1 , & selectset ,
985987 NULL , NULL , timeoutp );
988+ err = errno ;
986989 if (PyOS_InputHook ) PyOS_InputHook ();
987990 }
988991
989- if (has_input > 0 ) {
992+ if (has_input > 0 ) {
990993 rl_callback_read_char ();
991994 }
992- else if (errno == EINTR ) {
995+ else if (err == EINTR ) {
993996 int s ;
994997#ifdef WITH_THREAD
995998 PyEval_RestoreThread (_PyOS_ReadlineTState );
0 commit comments