@@ -39,11 +39,15 @@ static PyObject *msvcrt_locking(PyObject *self, PyObject *args)
3939 int fd ;
4040 int mode ;
4141 long nbytes ;
42+ int err ;
4243
4344 if (!PyArg_ParseTuple (args , "iil:locking" , & fd , & mode , & nbytes ))
4445 return NULL ;
4546
46- if (_locking (fd , mode , nbytes ) != 0 )
47+ Py_BEGIN_ALLOW_THREADS
48+ err = _locking (fd , mode , nbytes );
49+ Py_END_ALLOW_THREADS
50+ if (err != 0 )
4751 return PyErr_SetFromErrno (PyExc_IOError );
4852
4953 Py_INCREF (Py_None );
@@ -73,7 +77,7 @@ static PyObject *msvcrt_open_osfhandle(PyObject *self, PyObject *args)
7377 int fd ;
7478
7579 if (!PyArg_ParseTuple (args , "li:open_osfhandle" , & handle , & flags ))
76- return PyErr_SetFromErrno ( PyExc_IOError ) ;
80+ return NULL ;
7781
7882 fd = _open_osfhandle (handle , flags );
7983 if (fd == -1 )
@@ -120,7 +124,9 @@ static PyObject *msvcrt_getch(PyObject *self, PyObject *args)
120124 if (!PyArg_ParseTuple (args , ":getch" ))
121125 return NULL ;
122126
127+ Py_BEGIN_ALLOW_THREADS
123128 ch = _getch ();
129+ Py_END_ALLOW_THREADS
124130 s [0 ] = ch ;
125131 return PyString_FromStringAndSize (s , 1 );
126132}
@@ -133,7 +139,9 @@ static PyObject *msvcrt_getche(PyObject *self, PyObject *args)
133139 if (!PyArg_ParseTuple (args , ":getche" ))
134140 return NULL ;
135141
142+ Py_BEGIN_ALLOW_THREADS
136143 ch = _getche ();
144+ Py_END_ALLOW_THREADS
137145 s [0 ] = ch ;
138146 return PyString_FromStringAndSize (s , 1 );
139147}
0 commit comments