Remove extraneous whitespace.

This commit is contained in:
Brett Cannon 2010-05-05 20:15:14 +00:00
parent a1b562943b
commit 7a4cd7e1e2
3 changed files with 51 additions and 51 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Definition of a `Connection` type. * Definition of a `Connection` type.
* Used by `socket_connection.c` and `pipe_connection.c`. * Used by `socket_connection.c` and `pipe_connection.c`.
* *
* connection.h * connection.h
@ -42,7 +42,7 @@ connection_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"handle", "readable", "writable", NULL}; static char *kwlist[] = {"handle", "readable", "writable", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, F_HANDLE "|ii", kwlist, if (!PyArg_ParseTupleAndKeywords(args, kwds, F_HANDLE "|ii", kwlist,
&handle, &readable, &writable)) &handle, &readable, &writable))
return NULL; return NULL;
@ -53,7 +53,7 @@ connection_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
} }
if (!readable && !writable) { if (!readable && !writable) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"either readable or writable must be true"); "either readable or writable must be true");
return NULL; return NULL;
} }
@ -120,10 +120,10 @@ connection_sendbytes(ConnectionObject *self, PyObject *args)
} else { } else {
if (size < 0) { if (size < 0) {
PyErr_SetString(PyExc_ValueError, "size is negative"); PyErr_SetString(PyExc_ValueError, "size is negative");
return NULL; return NULL;
} }
if (offset + size > length) { if (offset + size > length) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"buffer length < offset + size"); "buffer length < offset + size");
return NULL; return NULL;
} }
@ -142,7 +142,7 @@ connection_sendbytes(ConnectionObject *self, PyObject *args)
} }
static PyObject * static PyObject *
connection_recvbytes(ConnectionObject *self, PyObject *args) connection_recvbytes(ConnectionObject *self, PyObject *args)
{ {
char *freeme = NULL; char *freeme = NULL;
Py_ssize_t res, maxlength = PY_SSIZE_T_MAX; Py_ssize_t res, maxlength = PY_SSIZE_T_MAX;
@ -152,15 +152,15 @@ connection_recvbytes(ConnectionObject *self, PyObject *args)
return NULL; return NULL;
CHECK_READABLE(self); CHECK_READABLE(self);
if (maxlength < 0) { if (maxlength < 0) {
PyErr_SetString(PyExc_ValueError, "maxlength < 0"); PyErr_SetString(PyExc_ValueError, "maxlength < 0");
return NULL; return NULL;
} }
res = conn_recv_string(self, self->buffer, CONNECTION_BUFFER_SIZE, res = conn_recv_string(self, self->buffer, CONNECTION_BUFFER_SIZE,
&freeme, maxlength); &freeme, maxlength);
if (res < 0) { if (res < 0) {
if (res == MP_BAD_MESSAGE_LENGTH) { if (res == MP_BAD_MESSAGE_LENGTH) {
if ((self->flags & WRITABLE) == 0) { if ((self->flags & WRITABLE) == 0) {
@ -173,7 +173,7 @@ connection_recvbytes(ConnectionObject *self, PyObject *args)
} }
} }
mp_SetError(PyExc_IOError, res); mp_SetError(PyExc_IOError, res);
} else { } else {
if (freeme == NULL) { if (freeme == NULL) {
result = PyString_FromStringAndSize(self->buffer, res); result = PyString_FromStringAndSize(self->buffer, res);
} else { } else {
@ -181,12 +181,12 @@ connection_recvbytes(ConnectionObject *self, PyObject *args)
PyMem_Free(freeme); PyMem_Free(freeme);
} }
} }
return result; return result;
} }
static PyObject * static PyObject *
connection_recvbytes_into(ConnectionObject *self, PyObject *args) connection_recvbytes_into(ConnectionObject *self, PyObject *args)
{ {
char *freeme = NULL, *buffer = NULL; char *freeme = NULL, *buffer = NULL;
Py_ssize_t res, length, offset = 0; Py_ssize_t res, length, offset = 0;
@ -194,8 +194,8 @@ connection_recvbytes_into(ConnectionObject *self, PyObject *args)
Py_buffer pbuf; Py_buffer pbuf;
CHECK_READABLE(self); CHECK_READABLE(self);
if (!PyArg_ParseTuple(args, "w*|" F_PY_SSIZE_T, if (!PyArg_ParseTuple(args, "w*|" F_PY_SSIZE_T,
&pbuf, &offset)) &pbuf, &offset))
return NULL; return NULL;
@ -205,14 +205,14 @@ connection_recvbytes_into(ConnectionObject *self, PyObject *args)
if (offset < 0) { if (offset < 0) {
PyErr_SetString(PyExc_ValueError, "negative offset"); PyErr_SetString(PyExc_ValueError, "negative offset");
goto _error; goto _error;
} }
if (offset > length) { if (offset > length) {
PyErr_SetString(PyExc_ValueError, "offset too large"); PyErr_SetString(PyExc_ValueError, "offset too large");
goto _error; goto _error;
} }
res = conn_recv_string(self, buffer+offset, length-offset, res = conn_recv_string(self, buffer+offset, length-offset,
&freeme, PY_SSIZE_T_MAX); &freeme, PY_SSIZE_T_MAX);
if (res < 0) { if (res < 0) {
@ -231,8 +231,8 @@ connection_recvbytes_into(ConnectionObject *self, PyObject *args)
if (freeme == NULL) { if (freeme == NULL) {
result = PyInt_FromSsize_t(res); result = PyInt_FromSsize_t(res);
} else { } else {
result = PyObject_CallFunction(BufferTooShort, result = PyObject_CallFunction(BufferTooShort,
F_RBUFFER "#", F_RBUFFER "#",
freeme, res); freeme, res);
PyMem_Free(freeme); PyMem_Free(freeme);
if (result) { if (result) {
@ -266,7 +266,7 @@ connection_send_obj(ConnectionObject *self, PyObject *obj)
CHECK_WRITABLE(self); CHECK_WRITABLE(self);
pickled_string = PyObject_CallFunctionObjArgs(pickle_dumps, obj, pickled_string = PyObject_CallFunctionObjArgs(pickle_dumps, obj,
pickle_protocol, NULL); pickle_protocol, NULL);
if (!pickled_string) if (!pickled_string)
goto failure; goto failure;
@ -298,7 +298,7 @@ connection_recv_obj(ConnectionObject *self)
CHECK_READABLE(self); CHECK_READABLE(self);
res = conn_recv_string(self, self->buffer, CONNECTION_BUFFER_SIZE, res = conn_recv_string(self, self->buffer, CONNECTION_BUFFER_SIZE,
&freeme, PY_SSIZE_T_MAX); &freeme, PY_SSIZE_T_MAX);
if (res < 0) { if (res < 0) {
@ -313,7 +313,7 @@ connection_recv_obj(ConnectionObject *self)
} }
} }
mp_SetError(PyExc_IOError, res); mp_SetError(PyExc_IOError, res);
} else { } else {
if (freeme == NULL) { if (freeme == NULL) {
temp = PyString_FromStringAndSize(self->buffer, res); temp = PyString_FromStringAndSize(self->buffer, res);
} else { } else {
@ -323,7 +323,7 @@ connection_recv_obj(ConnectionObject *self)
} }
if (temp) if (temp)
result = PyObject_CallFunctionObjArgs(pickle_loads, result = PyObject_CallFunctionObjArgs(pickle_loads,
temp, NULL); temp, NULL);
Py_XDECREF(temp); Py_XDECREF(temp);
return result; return result;
@ -400,7 +400,7 @@ connection_repr(ConnectionObject *self)
static char *conn_type[] = {"read-only", "write-only", "read-write"}; static char *conn_type[] = {"read-only", "write-only", "read-write"};
assert(self->flags >= 1 && self->flags <= 3); assert(self->flags >= 1 && self->flags <= 3);
return FROM_FORMAT("<%s %s, handle %zd>", return FROM_FORMAT("<%s %s, handle %zd>",
conn_type[self->flags - 1], conn_type[self->flags - 1],
CONNECTION_NAME, (Py_ssize_t)self->handle); CONNECTION_NAME, (Py_ssize_t)self->handle);
} }
@ -432,20 +432,20 @@ connection_writable(ConnectionObject *self, void *closure)
*/ */
static PyMethodDef connection_methods[] = { static PyMethodDef connection_methods[] = {
{"send_bytes", (PyCFunction)connection_sendbytes, METH_VARARGS, {"send_bytes", (PyCFunction)connection_sendbytes, METH_VARARGS,
"send the byte data from a readable buffer-like object"}, "send the byte data from a readable buffer-like object"},
{"recv_bytes", (PyCFunction)connection_recvbytes, METH_VARARGS, {"recv_bytes", (PyCFunction)connection_recvbytes, METH_VARARGS,
"receive byte data as a string"}, "receive byte data as a string"},
{"recv_bytes_into",(PyCFunction)connection_recvbytes_into,METH_VARARGS, {"recv_bytes_into",(PyCFunction)connection_recvbytes_into,METH_VARARGS,
"receive byte data into a writeable buffer-like object\n" "receive byte data into a writeable buffer-like object\n"
"returns the number of bytes read"}, "returns the number of bytes read"},
{"send", (PyCFunction)connection_send_obj, METH_O, {"send", (PyCFunction)connection_send_obj, METH_O,
"send a (picklable) object"}, "send a (picklable) object"},
{"recv", (PyCFunction)connection_recv_obj, METH_NOARGS, {"recv", (PyCFunction)connection_recv_obj, METH_NOARGS,
"receive a (picklable) object"}, "receive a (picklable) object"},
{"poll", (PyCFunction)connection_poll, METH_VARARGS, {"poll", (PyCFunction)connection_poll, METH_VARARGS,
"whether there is any input available to be read"}, "whether there is any input available to be read"},
{"fileno", (PyCFunction)connection_fileno, METH_NOARGS, {"fileno", (PyCFunction)connection_fileno, METH_NOARGS,
"file descriptor or handle of the connection"}, "file descriptor or handle of the connection"},
@ -456,11 +456,11 @@ static PyMethodDef connection_methods[] = {
}; };
static PyGetSetDef connection_getset[] = { static PyGetSetDef connection_getset[] = {
{"closed", (getter)connection_closed, NULL, {"closed", (getter)connection_closed, NULL,
"True if the connection is closed", NULL}, "True if the connection is closed", NULL},
{"readable", (getter)connection_readable, NULL, {"readable", (getter)connection_readable, NULL,
"True if the connection is readable", NULL}, "True if the connection is readable", NULL},
{"writable", (getter)connection_writable, NULL, {"writable", (getter)connection_writable, NULL,
"True if the connection is writable", NULL}, "True if the connection is writable", NULL},
{NULL} {NULL}
}; };
@ -494,7 +494,7 @@ PyTypeObject CONNECTION_TYPE = {
/* tp_getattro */ 0, /* tp_getattro */ 0,
/* tp_setattro */ 0, /* tp_setattro */ 0,
/* tp_as_buffer */ 0, /* tp_as_buffer */ 0,
/* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_HAVE_WEAKREFS, Py_TPFLAGS_HAVE_WEAKREFS,
/* tp_doc */ connection_doc, /* tp_doc */ connection_doc,
/* tp_traverse */ 0, /* tp_traverse */ 0,

View file

@ -39,7 +39,7 @@ conn_send_string(ConnectionObject *conn, char *string, size_t length)
*/ */
static Py_ssize_t static Py_ssize_t
conn_recv_string(ConnectionObject *conn, char *buffer, conn_recv_string(ConnectionObject *conn, char *buffer,
size_t buflength, char **newbuffer, size_t maxlength) size_t buflength, char **newbuffer, size_t maxlength)
{ {
DWORD left, length, full_length, err; DWORD left, length, full_length, err;
@ -130,7 +130,7 @@ conn_poll(ConnectionObject *conn, double timeout, PyThreadState *_save)
Sleep(delay); Sleep(delay);
/* check for signals */ /* check for signals */
Py_BLOCK_THREADS Py_BLOCK_THREADS
res = PyErr_CheckSignals(); res = PyErr_CheckSignals();
Py_UNBLOCK_THREADS Py_UNBLOCK_THREADS

View file

@ -26,7 +26,7 @@ win32_CloseHandle(PyObject *self, PyObject *args)
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
success = CloseHandle(hObject); success = CloseHandle(hObject);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (!success) if (!success)
@ -42,7 +42,7 @@ win32_ConnectNamedPipe(PyObject *self, PyObject *args)
LPOVERLAPPED lpOverlapped; LPOVERLAPPED lpOverlapped;
BOOL success; BOOL success;
if (!PyArg_ParseTuple(args, F_HANDLE F_POINTER, if (!PyArg_ParseTuple(args, F_HANDLE F_POINTER,
&hNamedPipe, &lpOverlapped)) &hNamedPipe, &lpOverlapped))
return NULL; return NULL;
@ -68,17 +68,17 @@ win32_CreateFile(PyObject *self, PyObject *args)
HANDLE hTemplateFile; HANDLE hTemplateFile;
HANDLE handle; HANDLE handle;
if (!PyArg_ParseTuple(args, "s" F_DWORD F_DWORD F_POINTER if (!PyArg_ParseTuple(args, "s" F_DWORD F_DWORD F_POINTER
F_DWORD F_DWORD F_HANDLE, F_DWORD F_DWORD F_HANDLE,
&lpFileName, &dwDesiredAccess, &dwShareMode, &lpFileName, &dwDesiredAccess, &dwShareMode,
&lpSecurityAttributes, &dwCreationDisposition, &lpSecurityAttributes, &dwCreationDisposition,
&dwFlagsAndAttributes, &hTemplateFile)) &dwFlagsAndAttributes, &hTemplateFile))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
handle = CreateFile(lpFileName, dwDesiredAccess, handle = CreateFile(lpFileName, dwDesiredAccess,
dwShareMode, lpSecurityAttributes, dwShareMode, lpSecurityAttributes,
dwCreationDisposition, dwCreationDisposition,
dwFlagsAndAttributes, hTemplateFile); dwFlagsAndAttributes, hTemplateFile);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
@ -101,17 +101,17 @@ win32_CreateNamedPipe(PyObject *self, PyObject *args)
LPSECURITY_ATTRIBUTES lpSecurityAttributes; LPSECURITY_ATTRIBUTES lpSecurityAttributes;
HANDLE handle; HANDLE handle;
if (!PyArg_ParseTuple(args, "s" F_DWORD F_DWORD F_DWORD if (!PyArg_ParseTuple(args, "s" F_DWORD F_DWORD F_DWORD
F_DWORD F_DWORD F_DWORD F_POINTER, F_DWORD F_DWORD F_DWORD F_POINTER,
&lpName, &dwOpenMode, &dwPipeMode, &lpName, &dwOpenMode, &dwPipeMode,
&nMaxInstances, &nOutBufferSize, &nMaxInstances, &nOutBufferSize,
&nInBufferSize, &nDefaultTimeOut, &nInBufferSize, &nDefaultTimeOut,
&lpSecurityAttributes)) &lpSecurityAttributes))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
handle = CreateNamedPipe(lpName, dwOpenMode, dwPipeMode, handle = CreateNamedPipe(lpName, dwOpenMode, dwPipeMode,
nMaxInstances, nOutBufferSize, nMaxInstances, nOutBufferSize,
nInBufferSize, nDefaultTimeOut, nInBufferSize, nDefaultTimeOut,
lpSecurityAttributes); lpSecurityAttributes);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
@ -155,11 +155,11 @@ win32_OpenProcess(PyObject *self, PyObject *args)
DWORD dwProcessId; DWORD dwProcessId;
HANDLE handle; HANDLE handle;
if (!PyArg_ParseTuple(args, F_DWORD "i" F_DWORD, if (!PyArg_ParseTuple(args, F_DWORD "i" F_DWORD,
&dwDesiredAccess, &bInheritHandle, &dwProcessId)) &dwDesiredAccess, &bInheritHandle, &dwProcessId))
return NULL; return NULL;
handle = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId); handle = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
if (handle == NULL) if (handle == NULL)
return PyErr_SetFromWindowsErr(0); return PyErr_SetFromWindowsErr(0);
@ -174,7 +174,7 @@ win32_SetNamedPipeHandleState(PyObject *self, PyObject *args)
DWORD dwArgs[3], *pArgs[3] = {NULL, NULL, NULL}; DWORD dwArgs[3], *pArgs[3] = {NULL, NULL, NULL};
int i; int i;
if (!PyArg_ParseTuple(args, F_HANDLE "OOO", if (!PyArg_ParseTuple(args, F_HANDLE "OOO",
&hNamedPipe, &oArgs[0], &oArgs[1], &oArgs[2])) &hNamedPipe, &oArgs[0], &oArgs[1], &oArgs[2]))
return NULL; return NULL;