@@ -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 ;
@@ -970,7 +972,7 @@ readline_until_enter_or_signal(char *prompt, int *signal)
970972 completed_input_string = not_done_reading ;
971973
972974 while (completed_input_string == not_done_reading ) {
973- int has_input = 0 ;
975+ int has_input = 0 , err = 0 ;
974976
975977 while (!has_input )
976978 { struct timeval timeout = {0 , 100000 }; /* 0.1 seconds */
@@ -984,13 +986,14 @@ readline_until_enter_or_signal(char *prompt, int *signal)
984986 /* select resets selectset if no input was available */
985987 has_input = select (fileno (rl_instream ) + 1 , & selectset ,
986988 NULL , NULL , timeoutp );
989+ err = errno ;
987990 if (PyOS_InputHook ) PyOS_InputHook ();
988991 }
989992
990- if (has_input > 0 ) {
993+ if (has_input > 0 ) {
991994 rl_callback_read_char ();
992995 }
993- else if (errno == EINTR ) {
996+ else if (err == EINTR ) {
994997 int s ;
995998#ifdef WITH_THREAD
996999 PyEval_RestoreThread (_PyOS_ReadlineTState );
0 commit comments