Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.

This commit is contained in:
Kristján Valur Jónsson 2009-02-10 13:32:24 +00:00
parent e71fc87112
commit 6a743d3694
4 changed files with 137 additions and 36 deletions

View file

@ -127,7 +127,7 @@ check_fd(int fd)
{
#if defined(HAVE_FSTAT)
struct stat buf;
if (fstat(fd, &buf) < 0 && errno == EBADF) {
if (!_PyVerify_fd(fd) || (fstat(fd, &buf) < 0 && errno == EBADF)) {
PyObject *exc;
char *msg = strerror(EBADF);
exc = PyObject_CallFunction(PyExc_OSError, "(is)",