summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Objects/bytesobject.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Objects/bytesobject.c
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Objects/bytesobject.c')
-rw-r--r--contrib/tools/python3/src/Objects/bytesobject.c394
1 files changed, 197 insertions, 197 deletions
diff --git a/contrib/tools/python3/src/Objects/bytesobject.c b/contrib/tools/python3/src/Objects/bytesobject.c
index d34ef53c482..25d9814dd6d 100644
--- a/contrib/tools/python3/src/Objects/bytesobject.c
+++ b/contrib/tools/python3/src/Objects/bytesobject.c
@@ -3,10 +3,10 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
-#include "pycore_abstract.h" // _PyIndex_Check()
-#include "pycore_bytes_methods.h"
-#include "pycore_object.h"
-#include "pycore_pymem.h" // PYMEM_CLEANBYTE
+#include "pycore_abstract.h" // _PyIndex_Check()
+#include "pycore_bytes_methods.h"
+#include "pycore_object.h"
+#include "pycore_pymem.h" // PYMEM_CLEANBYTE
#include "pystrhex.h"
#include <stddef.h>
@@ -21,8 +21,8 @@ class bytes "PyBytesObject *" "&PyBytes_Type"
static PyBytesObject *characters[UCHAR_MAX + 1];
static PyBytesObject *nullstring;
-_Py_IDENTIFIER(__bytes__);
-
+_Py_IDENTIFIER(__bytes__);
+
/* PyBytesObject_SIZE gives the basic size of a string; any memory allocation
for a string of length n should request PyBytesObject_SIZE + n bytes.
@@ -963,8 +963,8 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
if (res == NULL)
goto error;
}
-#ifndef NDEBUG
- char *before = res;
+#ifndef NDEBUG
+ char *before = res;
#endif
/* Write the sign if needed */
@@ -1029,7 +1029,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
}
Py_XDECREF(temp);
-#ifndef NDEBUG
+#ifndef NDEBUG
/* check that we computed the exact size for this write */
assert((res - before) == alloc);
#endif
@@ -1059,7 +1059,7 @@ _PyBytes_FormatEx(const char *format, Py_ssize_t format_len,
return NULL;
}
-/* Unescape a backslash-escaped string. */
+/* Unescape a backslash-escaped string. */
PyObject *_PyBytes_DecodeEscape(const char *s,
Py_ssize_t len,
const char *errors,
@@ -1082,7 +1082,7 @@ PyObject *_PyBytes_DecodeEscape(const char *s,
end = s + len;
while (s < end) {
if (*s != '\\') {
- *p++ = *s++;
+ *p++ = *s++;
continue;
}
@@ -1131,7 +1131,7 @@ PyObject *_PyBytes_DecodeEscape(const char *s,
if (!errors || strcmp(errors, "strict") == 0) {
PyErr_Format(PyExc_ValueError,
- "invalid \\x escape at position %zd",
+ "invalid \\x escape at position %zd",
s - 2 - (end - len));
goto failed;
}
@@ -1171,11 +1171,11 @@ PyObject *_PyBytes_DecodeEscape(const char *s,
PyObject *PyBytes_DecodeEscape(const char *s,
Py_ssize_t len,
const char *errors,
- Py_ssize_t Py_UNUSED(unicode),
- const char *Py_UNUSED(recode_encoding))
+ Py_ssize_t Py_UNUSED(unicode),
+ const char *Py_UNUSED(recode_encoding))
{
const char* first_invalid_escape;
- PyObject *result = _PyBytes_DecodeEscape(s, len, errors,
+ PyObject *result = _PyBytes_DecodeEscape(s, len, errors,
&first_invalid_escape);
if (result == NULL)
return NULL;
@@ -1264,14 +1264,14 @@ PyBytes_Repr(PyObject *obj, int smartquotes)
Py_ssize_t i, length = Py_SIZE(op);
Py_ssize_t newsize, squotes, dquotes;
PyObject *v;
- unsigned char quote;
- const unsigned char *s;
- Py_UCS1 *p;
+ unsigned char quote;
+ const unsigned char *s;
+ Py_UCS1 *p;
/* Compute size of output string */
squotes = dquotes = 0;
newsize = 3; /* b'' */
- s = (const unsigned char*)op->ob_sval;
+ s = (const unsigned char*)op->ob_sval;
for (i = 0; i < length; i++) {
Py_ssize_t incr = 1;
switch(s[i]) {
@@ -1341,11 +1341,11 @@ bytes_repr(PyObject *op)
static PyObject *
bytes_str(PyObject *op)
{
- if (_Py_GetConfig()->bytes_warning) {
+ if (_Py_GetConfig()->bytes_warning) {
if (PyErr_WarnEx(PyExc_BytesWarning,
- "str() on a bytes instance", 1)) {
+ "str() on a bytes instance", 1)) {
return NULL;
- }
+ }
}
return bytes_repr(op);
}
@@ -1498,7 +1498,7 @@ bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
/* Make sure both arguments are strings. */
if (!(PyBytes_Check(a) && PyBytes_Check(b))) {
- if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
+ if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
rc = PyObject_IsInstance((PyObject*)a,
(PyObject*)&PyUnicode_Type);
if (!rc)
@@ -1579,7 +1579,7 @@ bytes_hash(PyBytesObject *a)
static PyObject*
bytes_subscript(PyBytesObject* self, PyObject* item)
{
- if (_PyIndex_Check(item)) {
+ if (_PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
@@ -1593,9 +1593,9 @@ bytes_subscript(PyBytesObject* self, PyObject* item)
return PyLong_FromLong((unsigned char)self->ob_sval[i]);
}
else if (PySlice_Check(item)) {
- Py_ssize_t start, stop, step, slicelength, i;
- size_t cur;
- const char* source_buf;
+ Py_ssize_t start, stop, step, slicelength, i;
+ size_t cur;
+ const char* source_buf;
char* result_buf;
PyObject* result;
@@ -1860,7 +1860,7 @@ Py_LOCAL_INLINE(PyObject *)
do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
{
Py_buffer vsep;
- const char *s = PyBytes_AS_STRING(self);
+ const char *s = PyBytes_AS_STRING(self);
Py_ssize_t len = PyBytes_GET_SIZE(self);
char *sep;
Py_ssize_t seplen;
@@ -1900,7 +1900,7 @@ do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
Py_LOCAL_INLINE(PyObject *)
do_strip(PyBytesObject *self, int striptype)
{
- const char *s = PyBytes_AS_STRING(self);
+ const char *s = PyBytes_AS_STRING(self);
Py_ssize_t len = PyBytes_GET_SIZE(self), i, j;
i = 0;
@@ -1930,7 +1930,7 @@ do_strip(PyBytesObject *self, int striptype)
Py_LOCAL_INLINE(PyObject *)
do_argstrip(PyBytesObject *self, int striptype, PyObject *bytes)
{
- if (bytes != Py_None) {
+ if (bytes != Py_None) {
return do_xstrip(self, striptype, bytes);
}
return do_strip(self, striptype);
@@ -2017,8 +2017,8 @@ bytes_translate_impl(PyBytesObject *self, PyObject *table,
PyObject *deletechars)
/*[clinic end generated code: output=43be3437f1956211 input=0ecdf159f654233c]*/
{
- const char *input;
- char *output;
+ const char *input;
+ char *output;
Py_buffer table_view = {NULL, NULL};
Py_buffer del_table_view = {NULL, NULL};
const char *table_chars;
@@ -2182,83 +2182,83 @@ bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new,
/** End DALKE **/
-/*[clinic input]
-bytes.removeprefix as bytes_removeprefix
+/*[clinic input]
+bytes.removeprefix as bytes_removeprefix
+
+ prefix: Py_buffer
+ /
+
+Return a bytes object with the given prefix string removed if present.
+
+If the bytes starts with the prefix string, return bytes[len(prefix):].
+Otherwise, return a copy of the original bytes.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_removeprefix_impl(PyBytesObject *self, Py_buffer *prefix)
+/*[clinic end generated code: output=f006865331a06ab6 input=0c93bac817a8502c]*/
+{
+ const char *self_start = PyBytes_AS_STRING(self);
+ Py_ssize_t self_len = PyBytes_GET_SIZE(self);
+ const char *prefix_start = prefix->buf;
+ Py_ssize_t prefix_len = prefix->len;
+
+ if (self_len >= prefix_len
+ && prefix_len > 0
+ && memcmp(self_start, prefix_start, prefix_len) == 0)
+ {
+ return PyBytes_FromStringAndSize(self_start + prefix_len,
+ self_len - prefix_len);
+ }
+
+ if (PyBytes_CheckExact(self)) {
+ Py_INCREF(self);
+ return (PyObject *)self;
+ }
+
+ return PyBytes_FromStringAndSize(self_start, self_len);
+}
+
+/*[clinic input]
+bytes.removesuffix as bytes_removesuffix
+
+ suffix: Py_buffer
+ /
+
+Return a bytes object with the given suffix string removed if present.
+
+If the bytes ends with the suffix string and that suffix is not empty,
+return bytes[:-len(prefix)]. Otherwise, return a copy of the original
+bytes.
+[clinic start generated code]*/
+
+static PyObject *
+bytes_removesuffix_impl(PyBytesObject *self, Py_buffer *suffix)
+/*[clinic end generated code: output=d887d308e3242eeb input=9f4e1da8c637bbf1]*/
+{
+ const char *self_start = PyBytes_AS_STRING(self);
+ Py_ssize_t self_len = PyBytes_GET_SIZE(self);
+ const char *suffix_start = suffix->buf;
+ Py_ssize_t suffix_len = suffix->len;
+
+ if (self_len >= suffix_len
+ && suffix_len > 0
+ && memcmp(self_start + self_len - suffix_len,
+ suffix_start, suffix_len) == 0)
+ {
+ return PyBytes_FromStringAndSize(self_start,
+ self_len - suffix_len);
+ }
+
+ if (PyBytes_CheckExact(self)) {
+ Py_INCREF(self);
+ return (PyObject *)self;
+ }
+
+ return PyBytes_FromStringAndSize(self_start, self_len);
+}
- prefix: Py_buffer
- /
-
-Return a bytes object with the given prefix string removed if present.
-
-If the bytes starts with the prefix string, return bytes[len(prefix):].
-Otherwise, return a copy of the original bytes.
-[clinic start generated code]*/
-
static PyObject *
-bytes_removeprefix_impl(PyBytesObject *self, Py_buffer *prefix)
-/*[clinic end generated code: output=f006865331a06ab6 input=0c93bac817a8502c]*/
-{
- const char *self_start = PyBytes_AS_STRING(self);
- Py_ssize_t self_len = PyBytes_GET_SIZE(self);
- const char *prefix_start = prefix->buf;
- Py_ssize_t prefix_len = prefix->len;
-
- if (self_len >= prefix_len
- && prefix_len > 0
- && memcmp(self_start, prefix_start, prefix_len) == 0)
- {
- return PyBytes_FromStringAndSize(self_start + prefix_len,
- self_len - prefix_len);
- }
-
- if (PyBytes_CheckExact(self)) {
- Py_INCREF(self);
- return (PyObject *)self;
- }
-
- return PyBytes_FromStringAndSize(self_start, self_len);
-}
-
-/*[clinic input]
-bytes.removesuffix as bytes_removesuffix
-
- suffix: Py_buffer
- /
-
-Return a bytes object with the given suffix string removed if present.
-
-If the bytes ends with the suffix string and that suffix is not empty,
-return bytes[:-len(prefix)]. Otherwise, return a copy of the original
-bytes.
-[clinic start generated code]*/
-
-static PyObject *
-bytes_removesuffix_impl(PyBytesObject *self, Py_buffer *suffix)
-/*[clinic end generated code: output=d887d308e3242eeb input=9f4e1da8c637bbf1]*/
-{
- const char *self_start = PyBytes_AS_STRING(self);
- Py_ssize_t self_len = PyBytes_GET_SIZE(self);
- const char *suffix_start = suffix->buf;
- Py_ssize_t suffix_len = suffix->len;
-
- if (self_len >= suffix_len
- && suffix_len > 0
- && memcmp(self_start + self_len - suffix_len,
- suffix_start, suffix_len) == 0)
- {
- return PyBytes_FromStringAndSize(self_start,
- self_len - suffix_len);
- }
-
- if (PyBytes_CheckExact(self)) {
- Py_INCREF(self);
- return (PyObject *)self;
- }
-
- return PyBytes_FromStringAndSize(self_start, self_len);
-}
-
-static PyObject *
bytes_startswith(PyBytesObject *self, PyObject *args)
{
return _Py_bytes_startswith(PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self), args);
@@ -2335,7 +2335,7 @@ bytes_fromhex_impl(PyTypeObject *type, PyObject *string)
{
PyObject *result = _PyBytes_FromHex(string, 0);
if (type != &PyBytes_Type && result != NULL) {
- Py_SETREF(result, PyObject_CallOneArg((PyObject *)type, result));
+ Py_SETREF(result, PyObject_CallOneArg((PyObject *)type, result));
}
return result;
}
@@ -2346,7 +2346,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
char *buf;
Py_ssize_t hexlen, invalid_char;
unsigned int top, bot;
- const Py_UCS1 *str, *end;
+ const Py_UCS1 *str, *end;
_PyBytesWriter writer;
_PyBytesWriter_Init(&writer);
@@ -2358,7 +2358,7 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
hexlen = PyUnicode_GET_LENGTH(string);
if (!PyUnicode_IS_ASCII(string)) {
- const void *data = PyUnicode_DATA(string);
+ const void *data = PyUnicode_DATA(string);
unsigned int kind = PyUnicode_KIND(string);
Py_ssize_t i;
@@ -2417,40 +2417,40 @@ _PyBytes_FromHex(PyObject *string, int use_bytearray)
return NULL;
}
-/*[clinic input]
-bytes.hex
+/*[clinic input]
+bytes.hex
+
+ sep: object = NULL
+ An optional single character or byte to separate hex bytes.
+ bytes_per_sep: int = 1
+ How many bytes between separators. Positive values count from the
+ right, negative values count from the left.
+
+Create a str of hexadecimal numbers from a bytes object.
+
+Example:
+>>> value = b'\xb9\x01\xef'
+>>> value.hex()
+'b901ef'
+>>> value.hex(':')
+'b9:01:ef'
+>>> value.hex(':', 2)
+'b9:01ef'
+>>> value.hex(':', -2)
+'b901:ef'
+[clinic start generated code]*/
- sep: object = NULL
- An optional single character or byte to separate hex bytes.
- bytes_per_sep: int = 1
- How many bytes between separators. Positive values count from the
- right, negative values count from the left.
-
-Create a str of hexadecimal numbers from a bytes object.
-
-Example:
->>> value = b'\xb9\x01\xef'
->>> value.hex()
-'b901ef'
->>> value.hex(':')
-'b9:01:ef'
->>> value.hex(':', 2)
-'b9:01ef'
->>> value.hex(':', -2)
-'b901:ef'
-[clinic start generated code]*/
-
static PyObject *
-bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep)
-/*[clinic end generated code: output=1f134da504064139 input=f1238d3455990218]*/
+bytes_hex_impl(PyBytesObject *self, PyObject *sep, int bytes_per_sep)
+/*[clinic end generated code: output=1f134da504064139 input=f1238d3455990218]*/
{
- const char *argbuf = PyBytes_AS_STRING(self);
+ const char *argbuf = PyBytes_AS_STRING(self);
Py_ssize_t arglen = PyBytes_GET_SIZE(self);
- return _Py_strhex_with_sep(argbuf, arglen, sep, bytes_per_sep);
+ return _Py_strhex_with_sep(argbuf, arglen, sep, bytes_per_sep);
}
static PyObject *
-bytes_getnewargs(PyBytesObject *v, PyObject *Py_UNUSED(ignored))
+bytes_getnewargs(PyBytesObject *v, PyObject *Py_UNUSED(ignored))
{
return Py_BuildValue("(y#)", v->ob_sval, Py_SIZE(v));
}
@@ -2459,48 +2459,48 @@ bytes_getnewargs(PyBytesObject *v, PyObject *Py_UNUSED(ignored))
static PyMethodDef
bytes_methods[] = {
{"__getnewargs__", (PyCFunction)bytes_getnewargs, METH_NOARGS},
- {"capitalize", stringlib_capitalize, METH_NOARGS,
+ {"capitalize", stringlib_capitalize, METH_NOARGS,
_Py_capitalize__doc__},
- STRINGLIB_CENTER_METHODDEF
+ STRINGLIB_CENTER_METHODDEF
{"count", (PyCFunction)bytes_count, METH_VARARGS,
_Py_count__doc__},
BYTES_DECODE_METHODDEF
{"endswith", (PyCFunction)bytes_endswith, METH_VARARGS,
_Py_endswith__doc__},
- STRINGLIB_EXPANDTABS_METHODDEF
+ STRINGLIB_EXPANDTABS_METHODDEF
{"find", (PyCFunction)bytes_find, METH_VARARGS,
_Py_find__doc__},
BYTES_FROMHEX_METHODDEF
- BYTES_HEX_METHODDEF
+ BYTES_HEX_METHODDEF
{"index", (PyCFunction)bytes_index, METH_VARARGS, _Py_index__doc__},
- {"isalnum", stringlib_isalnum, METH_NOARGS,
+ {"isalnum", stringlib_isalnum, METH_NOARGS,
_Py_isalnum__doc__},
- {"isalpha", stringlib_isalpha, METH_NOARGS,
+ {"isalpha", stringlib_isalpha, METH_NOARGS,
_Py_isalpha__doc__},
- {"isascii", stringlib_isascii, METH_NOARGS,
+ {"isascii", stringlib_isascii, METH_NOARGS,
_Py_isascii__doc__},
- {"isdigit", stringlib_isdigit, METH_NOARGS,
+ {"isdigit", stringlib_isdigit, METH_NOARGS,
_Py_isdigit__doc__},
- {"islower", stringlib_islower, METH_NOARGS,
+ {"islower", stringlib_islower, METH_NOARGS,
_Py_islower__doc__},
- {"isspace", stringlib_isspace, METH_NOARGS,
+ {"isspace", stringlib_isspace, METH_NOARGS,
_Py_isspace__doc__},
- {"istitle", stringlib_istitle, METH_NOARGS,
+ {"istitle", stringlib_istitle, METH_NOARGS,
_Py_istitle__doc__},
- {"isupper", stringlib_isupper, METH_NOARGS,
+ {"isupper", stringlib_isupper, METH_NOARGS,
_Py_isupper__doc__},
BYTES_JOIN_METHODDEF
- STRINGLIB_LJUST_METHODDEF
- {"lower", stringlib_lower, METH_NOARGS, _Py_lower__doc__},
+ STRINGLIB_LJUST_METHODDEF
+ {"lower", stringlib_lower, METH_NOARGS, _Py_lower__doc__},
BYTES_LSTRIP_METHODDEF
BYTES_MAKETRANS_METHODDEF
BYTES_PARTITION_METHODDEF
BYTES_REPLACE_METHODDEF
- BYTES_REMOVEPREFIX_METHODDEF
- BYTES_REMOVESUFFIX_METHODDEF
+ BYTES_REMOVEPREFIX_METHODDEF
+ BYTES_REMOVESUFFIX_METHODDEF
{"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, _Py_rfind__doc__},
{"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, _Py_rindex__doc__},
- STRINGLIB_RJUST_METHODDEF
+ STRINGLIB_RJUST_METHODDEF
BYTES_RPARTITION_METHODDEF
BYTES_RSPLIT_METHODDEF
BYTES_RSTRIP_METHODDEF
@@ -2509,12 +2509,12 @@ bytes_methods[] = {
{"startswith", (PyCFunction)bytes_startswith, METH_VARARGS,
_Py_startswith__doc__},
BYTES_STRIP_METHODDEF
- {"swapcase", stringlib_swapcase, METH_NOARGS,
+ {"swapcase", stringlib_swapcase, METH_NOARGS,
_Py_swapcase__doc__},
- {"title", stringlib_title, METH_NOARGS, _Py_title__doc__},
+ {"title", stringlib_title, METH_NOARGS, _Py_title__doc__},
BYTES_TRANSLATE_METHODDEF
- {"upper", stringlib_upper, METH_NOARGS, _Py_upper__doc__},
- STRINGLIB_ZFILL_METHODDEF
+ {"upper", stringlib_upper, METH_NOARGS, _Py_upper__doc__},
+ STRINGLIB_ZFILL_METHODDEF
{NULL, NULL} /* sentinel */
};
@@ -2557,9 +2557,9 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (x == NULL) {
if (encoding != NULL || errors != NULL) {
PyErr_SetString(PyExc_TypeError,
- encoding != NULL ?
- "encoding without a string argument" :
- "errors without a string argument");
+ encoding != NULL ?
+ "encoding without a string argument" :
+ "errors without a string argument");
return NULL;
}
return PyBytes_FromStringAndSize(NULL, 0);
@@ -2614,7 +2614,7 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
/* Is it an integer? */
- if (_PyIndex_Check(x)) {
+ if (_PyIndex_Check(x)) {
size = PyNumber_AsSsize_t(x, PyExc_OverflowError);
if (size == -1 && PyErr_Occurred()) {
if (!PyErr_ExceptionMatches(PyExc_TypeError))
@@ -2840,7 +2840,7 @@ PyBytes_FromObject(PyObject *x)
PyErr_Format(PyExc_TypeError,
"cannot convert '%.200s' object to bytes",
- Py_TYPE(x)->tp_name);
+ Py_TYPE(x)->tp_name);
return NULL;
}
@@ -2887,11 +2887,11 @@ PyTypeObject PyBytes_Type = {
"bytes",
PyBytesObject_SIZE,
sizeof(char),
- 0, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_dealloc */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc)bytes_repr, /* tp_repr */
&bytes_as_number, /* tp_as_number */
&bytes_as_sequence, /* tp_as_sequence */
@@ -3026,12 +3026,12 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
return (*pv == NULL) ? -1 : 0;
}
/* XXX UNREF/NEWREF interface should be more symmetrical */
-#ifdef Py_REF_DEBUG
- _Py_RefTotal--;
-#endif
-#ifdef Py_TRACE_REFS
+#ifdef Py_REF_DEBUG
+ _Py_RefTotal--;
+#endif
+#ifdef Py_TRACE_REFS
_Py_ForgetReference(v);
-#endif
+#endif
*pv = (PyObject *)
PyObject_REALLOC(v, PyBytesObject_SIZE + newsize);
if (*pv == NULL) {
@@ -3041,7 +3041,7 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
}
_Py_NewReference(*pv);
sv = (PyBytesObject *) *pv;
- Py_SET_SIZE(sv, newsize);
+ Py_SET_SIZE(sv, newsize);
sv->ob_sval[newsize] = '\0';
sv->ob_shash = -1; /* invalidate cached hash value */
return 0;
@@ -3053,7 +3053,7 @@ error:
}
void
-_PyBytes_Fini(void)
+_PyBytes_Fini(void)
{
int i;
for (i = 0; i < UCHAR_MAX + 1; i++)
@@ -3110,7 +3110,7 @@ striter_next(striterobject *it)
}
static PyObject *
-striter_len(striterobject *it, PyObject *Py_UNUSED(ignored))
+striter_len(striterobject *it, PyObject *Py_UNUSED(ignored))
{
Py_ssize_t len = 0;
if (it->it_seq)
@@ -3122,14 +3122,14 @@ PyDoc_STRVAR(length_hint_doc,
"Private method returning an estimate of len(list(it)).");
static PyObject *
-striter_reduce(striterobject *it, PyObject *Py_UNUSED(ignored))
+striter_reduce(striterobject *it, PyObject *Py_UNUSED(ignored))
{
- _Py_IDENTIFIER(iter);
+ _Py_IDENTIFIER(iter);
if (it->it_seq != NULL) {
- return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
+ return Py_BuildValue("N(O)n", _PyEval_GetBuiltinId(&PyId_iter),
it->it_seq, it->it_index);
} else {
- return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter));
+ return Py_BuildValue("N(())", _PyEval_GetBuiltinId(&PyId_iter));
}
}
@@ -3170,10 +3170,10 @@ PyTypeObject PyBytesIter_Type = {
0, /* tp_itemsize */
/* methods */
(destructor)striter_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -3231,9 +3231,9 @@ _PyBytesWriter_Init(_PyBytesWriter *writer)
{
/* Set all attributes before small_buffer to 0 */
memset(writer, 0, offsetof(_PyBytesWriter, small_buffer));
-#ifndef NDEBUG
- memset(writer->small_buffer, PYMEM_CLEANBYTE,
- sizeof(writer->small_buffer));
+#ifndef NDEBUG
+ memset(writer->small_buffer, PYMEM_CLEANBYTE,
+ sizeof(writer->small_buffer));
#endif
}
@@ -3263,18 +3263,18 @@ _PyBytesWriter_AsString(_PyBytesWriter *writer)
Py_LOCAL_INLINE(Py_ssize_t)
_PyBytesWriter_GetSize(_PyBytesWriter *writer, char *str)
{
- const char *start = _PyBytesWriter_AsString(writer);
+ const char *start = _PyBytesWriter_AsString(writer);
assert(str != NULL);
assert(str >= start);
assert(str - start <= writer->allocated);
return str - start;
}
-#ifndef NDEBUG
-Py_LOCAL_INLINE(int)
+#ifndef NDEBUG
+Py_LOCAL_INLINE(int)
_PyBytesWriter_CheckConsistency(_PyBytesWriter *writer, char *str)
{
- const char *start, *end;
+ const char *start, *end;
if (writer->use_small_buffer) {
assert(writer->buffer == NULL);
@@ -3303,8 +3303,8 @@ _PyBytesWriter_CheckConsistency(_PyBytesWriter *writer, char *str)
end = start + writer->allocated;
assert(str != NULL);
assert(start <= str && str <= end);
- return 1;
-}
+ return 1;
+}
#endif
void*
@@ -3312,7 +3312,7 @@ _PyBytesWriter_Resize(_PyBytesWriter *writer, void *str, Py_ssize_t size)
{
Py_ssize_t allocated, pos;
- assert(_PyBytesWriter_CheckConsistency(writer, str));
+ assert(_PyBytesWriter_CheckConsistency(writer, str));
assert(writer->allocated < size);
allocated = size;
@@ -3361,15 +3361,15 @@ _PyBytesWriter_Resize(_PyBytesWriter *writer, void *str, Py_ssize_t size)
}
writer->use_small_buffer = 0;
-#ifndef NDEBUG
- memset(writer->small_buffer, PYMEM_CLEANBYTE,
- sizeof(writer->small_buffer));
+#ifndef NDEBUG
+ memset(writer->small_buffer, PYMEM_CLEANBYTE,
+ sizeof(writer->small_buffer));
#endif
}
writer->allocated = allocated;
str = _PyBytesWriter_AsString(writer) + pos;
- assert(_PyBytesWriter_CheckConsistency(writer, str));
+ assert(_PyBytesWriter_CheckConsistency(writer, str));
return str;
error:
@@ -3382,7 +3382,7 @@ _PyBytesWriter_Prepare(_PyBytesWriter *writer, void *str, Py_ssize_t size)
{
Py_ssize_t new_min_size;
- assert(_PyBytesWriter_CheckConsistency(writer, str));
+ assert(_PyBytesWriter_CheckConsistency(writer, str));
assert(size >= 0);
if (size == 0) {
@@ -3415,7 +3415,7 @@ _PyBytesWriter_Alloc(_PyBytesWriter *writer, Py_ssize_t size)
assert(size >= 0);
writer->use_small_buffer = 1;
-#ifndef NDEBUG
+#ifndef NDEBUG
writer->allocated = sizeof(writer->small_buffer) - 1;
/* In debug mode, don't use the full small buffer because it is less
efficient than bytes and bytearray objects to detect buffer underflow
@@ -3443,7 +3443,7 @@ _PyBytesWriter_Finish(_PyBytesWriter *writer, void *str)
Py_ssize_t size;
PyObject *result;
- assert(_PyBytesWriter_CheckConsistency(writer, str));
+ assert(_PyBytesWriter_CheckConsistency(writer, str));
size = _PyBytesWriter_GetSize(writer, str);
if (size == 0 && !writer->use_bytearray) {