def test_is_valid_fd(self): if os.name != 'nt': skip('relevant for windows only') assert rposix.is_valid_fd(0) == 1 fid = open(str(udir.join('validate_test.txt')), 'w') fd = fid.fileno() assert rposix.is_valid_fd(fd) == 1 fid.close() assert rposix.is_valid_fd(fd) == 0
def _setfd_binary(fd): #Allow this to succeed on invalid fd's if rposix.is_valid_fd(fd): _setmode(fd, os.O_BINARY)
def fclose(fp): if not is_valid_fd(fileno(fp)): return -1 return _fclose(fp)