mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
PEP 7 clean ups, no change in behavior.
Reflow long lines. Remove whitespace inside parents. Move open braces off lines by themselves.
This commit is contained in:
parent
b4df71f095
commit
c4140a158e
1 changed files with 53 additions and 49 deletions
|
@ -25,7 +25,8 @@ get_buf(PyBufferObject *self, PyBuffer *view, int flags)
|
|||
else {
|
||||
Py_ssize_t count, offset;
|
||||
PyBufferProcs *bp = self->b_base->ob_type->tp_as_buffer;
|
||||
if ((*bp->bf_getbuffer)(self->b_base, view, flags) < 0) return 0;
|
||||
if ((*bp->bf_getbuffer)(self->b_base, view, flags) < 0)
|
||||
return 0;
|
||||
count = view->len;
|
||||
/* apply constraints to the start/end */
|
||||
if (self->b_offset > count)
|
||||
|
@ -50,7 +51,8 @@ buffer_getbuf(PyBufferObject *self, PyBuffer *view, int flags)
|
|||
if (view == NULL) return 0;
|
||||
if (!get_buf(self, view, flags))
|
||||
return -1;
|
||||
return PyBuffer_FillInfo(view, view->buf, view->len, self->b_readonly, flags);
|
||||
return PyBuffer_FillInfo(view, view->buf, view->len, self->b_readonly,
|
||||
flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,8 +69,8 @@ buffer_releasebuf(PyBufferObject *self, PyBuffer *view)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
buffer_from_memory(PyObject *base, Py_ssize_t size, Py_ssize_t offset, void *ptr,
|
||||
int readonly)
|
||||
buffer_from_memory(PyObject *base, Py_ssize_t size, Py_ssize_t offset,
|
||||
void *ptr, int readonly)
|
||||
{
|
||||
PyBufferObject * b;
|
||||
|
||||
|
@ -99,7 +101,8 @@ buffer_from_memory(PyObject *base, Py_ssize_t size, Py_ssize_t offset, void *ptr
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
buffer_from_object(PyObject *base, Py_ssize_t size, Py_ssize_t offset, int readonly)
|
||||
buffer_from_object(PyObject *base, Py_ssize_t size, Py_ssize_t offset,
|
||||
int readonly)
|
||||
{
|
||||
if (offset < 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
|
@ -138,7 +141,8 @@ PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)
|
||||
PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset,
|
||||
Py_ssize_t size)
|
||||
{
|
||||
PyBufferProcs *pb = base->ob_type->tp_as_buffer;
|
||||
|
||||
|
@ -295,7 +299,8 @@ buffer_repr(PyBufferObject *self)
|
|||
const char *status = self->b_readonly ? "read-only" : "read-write";
|
||||
|
||||
if (self->b_base == NULL)
|
||||
return PyUnicode_FromFormat("<%s buffer ptr %p, size %zd at %p>",
|
||||
return PyUnicode_FromFormat(
|
||||
"<%s buffer ptr %p, size %zd at %p>",
|
||||
status,
|
||||
self->b_ptr,
|
||||
self->b_size,
|
||||
|
@ -433,8 +438,7 @@ buffer_repeat(PyBufferObject *self, Py_ssize_t count)
|
|||
return NULL;
|
||||
|
||||
p = PyBytes_AS_STRING(ob);
|
||||
while ( count-- )
|
||||
{
|
||||
while (count--) {
|
||||
memcpy(p, view.buf, view.len);
|
||||
p += view.len;
|
||||
}
|
||||
|
@ -601,7 +605,8 @@ buffer_ass_item(PyBufferObject *self, Py_ssize_t idx, PyObject *other)
|
|||
}
|
||||
|
||||
static int
|
||||
buffer_ass_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right, PyObject *other)
|
||||
buffer_ass_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right,
|
||||
PyObject *other)
|
||||
{
|
||||
PyBufferProcs *pb;
|
||||
PyBuffer v1, v2;
|
||||
|
@ -609,8 +614,7 @@ buffer_ass_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right, PyObje
|
|||
|
||||
pb = other ? other->ob_type->tp_as_buffer : NULL;
|
||||
if (pb == NULL ||
|
||||
pb->bf_getbuffer == NULL)
|
||||
{
|
||||
pb->bf_getbuffer == NULL) {
|
||||
PyErr_BadArgument();
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue