mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-42431: Fix outdated bytes comments (GH-23458)
Also move definitions of internal macros F_LJUST etc to private header.
This commit is contained in:
parent
f3c3ea91a7
commit
2ad93821a6
11 changed files with 65 additions and 60 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue