Skip to content

Commit 0b5cccd

Browse files
committed
gh-111178: Fix function signatures in bytesobject.c
1 parent 7e7223e commit 0b5cccd

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Objects/bytesobject.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,11 +1456,9 @@ bytes_concat(PyObject *a, PyObject *b)
14561456
}
14571457

14581458
static PyObject *
1459-
bytes_repeat(PyBytesObject *a, Py_ssize_t n)
1459+
bytes_repeat(PyObject *self, Py_ssize_t n)
14601460
{
1461-
Py_ssize_t size;
1462-
PyBytesObject *op;
1463-
size_t nbytes;
1461+
PyBytesObject *a = (PyBytesObject *)self;
14641462
if (n < 0)
14651463
n = 0;
14661464
/* watch out for overflows: the size can overflow int,
@@ -1471,16 +1469,17 @@ bytes_repeat(PyBytesObject *a, Py_ssize_t n)
14711469
"repeated bytes are too long");
14721470
return NULL;
14731471
}
1474-
size = Py_SIZE(a) * n;
1472+
Py_ssize_t size = Py_SIZE(a) * n;
14751473
if (size == Py_SIZE(a) && PyBytes_CheckExact(a)) {
14761474
return Py_NewRef(a);
14771475
}
1478-
nbytes = (size_t)size;
1476+
size_t nbytes = (size_t)size;
14791477
if (nbytes + PyBytesObject_SIZE <= nbytes) {
14801478
PyErr_SetString(PyExc_OverflowError,
14811479
"repeated bytes are too long");
14821480
return NULL;
14831481
}
1482+
PyBytesObject *op;
14841483
op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + nbytes);
14851484
if (op == NULL) {
14861485
return PyErr_NoMemory();
@@ -1531,8 +1530,10 @@ bytes_compare_eq(PyBytesObject *a, PyBytesObject *b)
15311530
}
15321531

15331532
static PyObject*
1534-
bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
1533+
bytes_richcompare(PyObject *arg, PyObject *arg2, int op)
15351534
{
1535+
PyBytesObject *a = (PyBytesObject *)arg;
1536+
PyBytesObject *b = (PyBytesObject *)arg2;
15361537
int c;
15371538
Py_ssize_t len_a, len_b;
15381539
Py_ssize_t min_len;
@@ -1592,8 +1593,9 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
15921593
}
15931594

15941595
static Py_hash_t
1595-
bytes_hash(PyBytesObject *a)
1596+
bytes_hash(PyObject *op)
15961597
{
1598+
PyBytesObject *a = (PyBytesObject *)op;
15971599
_Py_COMP_DIAG_PUSH
15981600
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
15991601
if (a->ob_shash == -1) {
@@ -1605,8 +1607,9 @@ _Py_COMP_DIAG_POP
16051607
}
16061608

16071609
static PyObject*
1608-
bytes_subscript(PyBytesObject* self, PyObject* item)
1610+
bytes_subscript(PyObject *op, PyObject* item)
16091611
{
1612+
PyBytesObject *self = (PyBytesObject *)op;
16101613
if (_PyIndex_Check(item)) {
16111614
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
16121615
if (i == -1 && PyErr_Occurred())
@@ -1670,8 +1673,9 @@ bytes_subscript(PyBytesObject* self, PyObject* item)
16701673
}
16711674

16721675
static int
1673-
bytes_buffer_getbuffer(PyBytesObject *self, Py_buffer *view, int flags)
1676+
bytes_buffer_getbuffer(PyObject *op, Py_buffer *view, int flags)
16741677
{
1678+
PyBytesObject *self = (PyBytesObject *)op;
16751679
return PyBuffer_FillInfo(view, (PyObject*)self, (void *)self->ob_sval, Py_SIZE(self),
16761680
1, flags);
16771681
}

0 commit comments

Comments
 (0)