mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	Release the interpreter lock for calls that may block: _locking(),
_getch(), _getche(). Fix bogus error return when open_osfhandle() doesn't have the right argument list.
This commit is contained in:
		
							parent
							
								
									00d93066b0
								
							
						
					
					
						commit
						e4e021bf21
					
				
					 1 changed files with 10 additions and 2 deletions
				
			
		| 
						 | 
					@ -39,11 +39,15 @@ static PyObject *msvcrt_locking(PyObject *self, PyObject *args)
 | 
				
			||||||
	int fd;
 | 
						int fd;
 | 
				
			||||||
	int mode;
 | 
						int mode;
 | 
				
			||||||
	long nbytes;
 | 
						long nbytes;
 | 
				
			||||||
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!PyArg_ParseTuple(args, "iil:locking", &fd, &mode, &nbytes))
 | 
						if (!PyArg_ParseTuple(args, "iil:locking", &fd, &mode, &nbytes))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (_locking(fd, mode, nbytes) != 0)
 | 
						Py_BEGIN_ALLOW_THREADS
 | 
				
			||||||
 | 
						err = _locking(fd, mode, nbytes);
 | 
				
			||||||
 | 
						Py_END_ALLOW_THREADS
 | 
				
			||||||
 | 
						if (err != 0)
 | 
				
			||||||
		return PyErr_SetFromErrno(PyExc_IOError);
 | 
							return PyErr_SetFromErrno(PyExc_IOError);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Py_INCREF(Py_None);
 | 
						Py_INCREF(Py_None);
 | 
				
			||||||
| 
						 | 
					@ -73,7 +77,7 @@ static PyObject *msvcrt_open_osfhandle(PyObject *self, PyObject *args)
 | 
				
			||||||
	int fd;
 | 
						int fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags))
 | 
						if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags))
 | 
				
			||||||
		return PyErr_SetFromErrno(PyExc_IOError);
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fd = _open_osfhandle(handle, flags);
 | 
						fd = _open_osfhandle(handle, flags);
 | 
				
			||||||
	if (fd == -1)
 | 
						if (fd == -1)
 | 
				
			||||||
| 
						 | 
					@ -120,7 +124,9 @@ static PyObject *msvcrt_getch(PyObject *self, PyObject *args)
 | 
				
			||||||
	if (!PyArg_ParseTuple(args, ":getch"))
 | 
						if (!PyArg_ParseTuple(args, ":getch"))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Py_BEGIN_ALLOW_THREADS
 | 
				
			||||||
	ch = _getch();
 | 
						ch = _getch();
 | 
				
			||||||
 | 
						Py_END_ALLOW_THREADS
 | 
				
			||||||
	s[0] = ch;
 | 
						s[0] = ch;
 | 
				
			||||||
	return PyString_FromStringAndSize(s, 1);
 | 
						return PyString_FromStringAndSize(s, 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -133,7 +139,9 @@ static PyObject *msvcrt_getche(PyObject *self, PyObject *args)
 | 
				
			||||||
	if (!PyArg_ParseTuple(args, ":getche"))
 | 
						if (!PyArg_ParseTuple(args, ":getche"))
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Py_BEGIN_ALLOW_THREADS
 | 
				
			||||||
	ch = _getche();
 | 
						ch = _getche();
 | 
				
			||||||
 | 
						Py_END_ALLOW_THREADS
 | 
				
			||||||
	s[0] = ch;
 | 
						s[0] = ch;
 | 
				
			||||||
	return PyString_FromStringAndSize(s, 1);
 | 
						return PyString_FromStringAndSize(s, 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue