Issue 3551: Raise ValueError if the size causes ERROR_NO_SYSTEM_RESOURCES

This commit is contained in:
Jesse Noller 2009-04-02 04:22:09 +00:00
parent 238cedcd63
commit 5053fbbb38
4 changed files with 21 additions and 4 deletions

View file

@ -23,6 +23,12 @@ conn_send_string(ConnectionObject *conn, char *string, size_t length)
Py_BEGIN_ALLOW_THREADS
ret = WriteFile(conn->handle, string, length, &amount_written, NULL);
Py_END_ALLOW_THREADS
if (ret == 0 && GetLastError() == ERROR_NO_SYSTEM_RESOURCES) {
PyErr_Format(PyExc_ValueError, "Cannnot send %" PY_FORMAT_SIZE_T "d bytes over connection", length);
return MP_STANDARD_ERROR;
}
return ret ? MP_SUCCESS : MP_STANDARD_ERROR;
}