summaryrefslogtreecommitdiffstats
path: root/Objects/bytearrayobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-12-03 10:46:16 (GMT)
committerGitHub <noreply@github.com>2020-12-03 10:46:16 (GMT)
commit2ad93821a69e6efac3b0efe1d205d6e5ef030791 (patch)
tree1f13d7f20f919864be2571adaa8a2e13daff4609 /Objects/bytearrayobject.c
parentf3c3ea91a76526edff928c95b9c6767e077b7448 (diff)
downloadcpython-2ad93821a69e6efac3b0efe1d205d6e5ef030791.zip
cpython-2ad93821a69e6efac3b0efe1d205d6e5ef030791.tar.gz
cpython-2ad93821a69e6efac3b0efe1d205d6e5ef030791.tar.bz2
bpo-42431: Fix outdated bytes comments (GH-23458)
Also move definitions of internal macros F_LJUST etc to private header.
Diffstat (limited to 'Objects/bytearrayobject.c')
-rw-r--r--Objects/bytearrayobject.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 805707a..7cb2b14 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -13,10 +13,9 @@ class bytearray "PyByteArrayObject *" "&PyByteArray_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5535b77c37a119e0]*/
+/* For PyByteArray_AS_STRING(). */
char _PyByteArray_empty_string[] = "";
-/* end nullbytes support */
-
/* Helpers */
static int
@@ -266,7 +265,7 @@ PyByteArray_Concat(PyObject *a, PyObject *b)
result = (PyByteArrayObject *) \
PyByteArray_FromStringAndSize(NULL, va.len + vb.len);
- // result->ob_bytes is NULL if result is an empty string:
+ // result->ob_bytes is NULL if result is an empty bytearray:
// if va.len + vb.len equals zero.
if (result != NULL && result->ob_bytes != NULL) {
memcpy(result->ob_bytes, va.buf, va.len);
@@ -1007,9 +1006,6 @@ bytearray_richcompare(PyObject *self, PyObject *other, int op)
Py_buffer self_bytes, other_bytes;
int cmp;
- /* Bytes can be compared to anything that supports the (binary)
- buffer API. Except that a comparison with Unicode is always an
- error, even if the comparison is for equality. */
if (!PyObject_CheckBuffer(self) || !PyObject_CheckBuffer(other)) {
if (PyUnicode_Check(self) || PyUnicode_Check(other)) {
if (_Py_GetConfig()->bytes_warning && (op == Py_EQ || op == Py_NE)) {
@@ -1021,6 +1017,7 @@ bytearray_richcompare(PyObject *self, PyObject *other, int op)
Py_RETURN_NOTIMPLEMENTED;
}
+ /* Bytearrays can be compared to anything that supports the buffer API. */
if (PyObject_GetBuffer(self, &self_bytes, PyBUF_SIMPLE) != 0) {
PyErr_Clear();
Py_RETURN_NOTIMPLEMENTED;
@@ -1328,7 +1325,7 @@ bytearray_translate_impl(PyByteArrayObject *self, PyObject *table,
if (trans_table[c] != -1)
*output++ = (char)trans_table[c];
}
- /* Fix the size of the resulting string */
+ /* Fix the size of the resulting bytearray */
if (inlen > 0)
if (PyByteArray_Resize(result, output - output_start) < 0) {
Py_CLEAR(result);
@@ -2083,7 +2080,7 @@ bytearray.hex
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 bytearray object.
+Create a string of hexadecimal numbers from a bytearray object.
Example:
>>> value = bytearray([0xb9, 0x01, 0xef])
@@ -2099,7 +2096,7 @@ Example:
static PyObject *
bytearray_hex_impl(PyByteArrayObject *self, PyObject *sep, int bytes_per_sep)
-/*[clinic end generated code: output=29c4e5ef72c565a0 input=814c15830ac8c4b5]*/
+/*[clinic end generated code: output=29c4e5ef72c565a0 input=808667e49bcccb54]*/
{
char* argbuf = PyByteArray_AS_STRING(self);
Py_ssize_t arglen = PyByteArray_GET_SIZE(self);
@@ -2358,7 +2355,7 @@ PyTypeObject PyByteArray_Type = {
PyObject_Del, /* tp_free */
};
-/*********************** Bytes Iterator ****************************/
+/*********************** Bytearray Iterator ****************************/
typedef struct {
PyObject_HEAD