-/* String object implementation */
-
-/* XXX This is now called 'bytes' as far as the user is concerned.
- Many docstrings and error messages need to be cleaned up. */
+/* bytes object implementation */
#define PY_SSIZE_T_CLEAN
size = strlen(str);
if (size > PY_SSIZE_T_MAX) {
PyErr_SetString(PyExc_OverflowError,
- "string is too long for a Python string");
+ "byte string is too long");
return NULL;
}
if (size == 0 && (op = nullstring) != NULL) {
size = Py_SIZE(a) * n;
if (n && size / n != Py_SIZE(a)) {
PyErr_SetString(PyExc_OverflowError,
- "repeated string is too long");
+ "repeated bytes are too long");
return NULL;
}
if (size == Py_SIZE(a) && PyBytes_CheckExact(a)) {
nbytes = (size_t)size;
if (nbytes + sizeof(PyBytesObject) <= nbytes) {
PyErr_SetString(PyExc_OverflowError,
- "repeated string is too long");
+ "repeated bytes are too long");
return NULL;
}
op = (PyBytesObject *)
string_item(PyBytesObject *a, register Py_ssize_t i)
{
if (i < 0 || i >= Py_SIZE(a)) {
- PyErr_SetString(PyExc_IndexError, "string index out of range");
+ PyErr_SetString(PyExc_IndexError, "index out of range");
return NULL;
}
return PyLong_FromLong((unsigned char)a->ob_sval[i]);
i += PyBytes_GET_SIZE(self);
if (i < 0 || i >= PyBytes_GET_SIZE(self)) {
PyErr_SetString(PyExc_IndexError,
- "string index out of range");
+ "index out of range");
return NULL;
}
return PyLong_FromLong((unsigned char)self->ob_sval[i]);
}
else {
PyErr_Format(PyExc_TypeError,
- "string indices must be integers, not %.200s",
+ "byte indices must be integers, not %.200s",
Py_TYPE(item)->tp_name);
return NULL;
}
}
PyDoc_STRVAR(rsplit__doc__,
-"B.rsplit([sep[, maxsplit]]) -> list of strings\n\
+"B.rsplit([sep[, maxsplit]]) -> list of bytes\n\
\n\
Return a list of the sections in B, using sep as the delimiter,\n\
starting at the end of B and working to the front.\n\
sz += seplen;
if (sz < old_sz || sz > PY_SSIZE_T_MAX) {
PyErr_SetString(PyExc_OverflowError,
- "join() result is too long for a Python string");
+ "join() result is too long for bytes");
Py_DECREF(seq);
return NULL;
}
product = count * to_len;
if (product / to_len != count) {
PyErr_SetString(PyExc_OverflowError,
- "replace string is too long");
+ "replacement bytes are too long");
return NULL;
}
result_len = product + self_len;
if (result_len < 0) {
PyErr_SetString(PyExc_OverflowError,
- "replace string is too long");
+ "replacement bytes are too long");
return NULL;
}
product = count * (to_len-1);
if (product / (to_len-1) != count) {
PyErr_SetString(PyExc_OverflowError,
- "replace string is too long");
+ "replacement bytes are too long");
return NULL;
}
result_len = self_len + product;
if (result_len < 0) {
PyErr_SetString(PyExc_OverflowError,
- "replace string is too long");
+ "replacment bytes are too long");
return NULL;
}
product = count * (to_len-from_len);
if (product / (to_len-from_len) != count) {
PyErr_SetString(PyExc_OverflowError,
- "replace string is too long");
+ "replacement bytes are too long");
return NULL;
}
result_len = self_len + product;
if (result_len < 0) {
PyErr_SetString(PyExc_OverflowError,
- "replace string is too long");
+ "replacement bytes are too long");
return NULL;
}
Return True if B starts with the specified prefix, False otherwise.\n\
With optional start, test B beginning at that position.\n\
With optional end, stop comparing B at that position.\n\
-prefix can also be a tuple of strings to try.");
+prefix can also be a tuple of bytes to try.");
static PyObject *
string_startswith(PyBytesObject *self, PyObject *args)
Return True if B ends with the specified suffix, False otherwise.\n\
With optional start, test B beginning at that position.\n\
With optional end, stop comparing B at that position.\n\
-suffix can also be a tuple of strings to try.");
+suffix can also be a tuple of bytes to try.");
static PyObject *
string_endswith(PyBytesObject *self, PyObject *args)
nullstring = NULL;
}
-/*********************** Str Iterator ****************************/
+/*********************** Bytes Iterator ****************************/
typedef struct {
PyObject_HEAD