[Python-3000-checkins] r63735 - python/branches/py3k/Objects/bytesobject.c
benjamin.peterson
python-3000-checkins at python.org
Tue May 27 02:36:20 CEST 2008
Author: benjamin.peterson
Date: Tue May 27 02:36:20 2008
New Revision: 63735
Log:
clean up some docstrings and errors in bytesobject.c
Modified:
python/branches/py3k/Objects/bytesobject.c
Modified: python/branches/py3k/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k/Objects/bytesobject.c (original)
+++ python/branches/py3k/Objects/bytesobject.c Tue May 27 02:36:20 2008
@@ -1,7 +1,4 @@
-/* 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
@@ -116,7 +113,7 @@
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) {
@@ -735,7 +732,7 @@
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)) {
@@ -745,7 +742,7 @@
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 *)
@@ -799,7 +796,7 @@
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]);
@@ -908,7 +905,7 @@
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]);
@@ -958,7 +955,7 @@
}
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;
}
@@ -1348,7 +1345,7 @@
}
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\
@@ -1482,7 +1479,7 @@
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;
}
@@ -2091,13 +2088,13 @@
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;
}
@@ -2346,13 +2343,13 @@
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;
}
@@ -2416,13 +2413,13 @@
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;
}
@@ -2620,7 +2617,7 @@
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)
@@ -2661,7 +2658,7 @@
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)
@@ -3310,7 +3307,7 @@
nullstring = NULL;
}
-/*********************** Str Iterator ****************************/
+/*********************** Bytes Iterator ****************************/
typedef struct {
PyObject_HEAD
More information about the Python-3000-checkins
mailing list