Fix all return types for str/bytes/bytearray docstrings and make the wording more consistent.

This commit is contained in:
Georg Brandl 2008-05-30 08:20:09 +00:00
parent 29e4f631ac
commit 17cb8a85d4
3 changed files with 81 additions and 77 deletions

View File

@ -2001,7 +2001,7 @@ replace(PyByteArrayObject *self,
}
if (to_len == 0) {
/* delete all occurances of 'from' bytes */
/* delete all occurrences of 'from' bytes */
if (from_len == 1) {
return replace_delete_single_character(
self, from_s[0], maxcount);
@ -2037,7 +2037,7 @@ replace(PyByteArrayObject *self,
PyDoc_STRVAR(replace__doc__,
"B.replace(old, new[, count]) -> bytes\n\
"B.replace(old, new[, count]) -> bytearray\n\
\n\
Return a copy of B with all occurrences of subsection\n\
old replaced by new. If the optional argument count is\n\
@ -2187,7 +2187,7 @@ split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxcount)
}
PyDoc_STRVAR(split__doc__,
"B.split([sep[, maxsplit]]) -> list of bytearray\n\
"B.split([sep[, maxsplit]]) -> list of bytearrays\n\
\n\
Return a list of the sections in B, using sep as the delimiter.\n\
If sep is not given, B is split on ASCII whitespace characters\n\
@ -2294,7 +2294,7 @@ make_nullbytes_unique(PyObject *result)
PyDoc_STRVAR(partition__doc__,
"B.partition(sep) -> (head, sep, tail)\n\
\n\
Searches for the separator sep in B, and returns the part before it,\n\
Search for the separator sep in B, and return the part before it,\n\
the separator itself, and the part after it. If the separator is not\n\
found, returns B and two empty bytearray objects.");
@ -2321,8 +2321,8 @@ bytes_partition(PyByteArrayObject *self, PyObject *sep_obj)
PyDoc_STRVAR(rpartition__doc__,
"B.rpartition(sep) -> (tail, sep, head)\n\
\n\
Searches for the separator sep in B, starting at the end of B,\n\
and returns the part before it, the separator itself, and the\n\
Search for the separator sep in B, starting at the end of B,\n\
and return the part before it, the separator itself, and the\n\
part after it. If the separator is not found, returns two empty\n\
bytearray objects and B.");
@ -2421,7 +2421,7 @@ rsplit_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxcount)
}
PyDoc_STRVAR(rsplit__doc__,
"B.rsplit(sep[, maxsplit]) -> list of bytearray\n\
"B.rsplit(sep[, maxsplit]) -> list of bytearrays\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\
@ -2578,7 +2578,7 @@ bytes_append(PyByteArrayObject *self, PyObject *arg)
}
PyDoc_STRVAR(extend__doc__,
"B.extend(iterable int) -> None\n\
"B.extend(iterable_of_ints) -> None\n\
\n\
Append all the elements from the iterator or sequence to the\n\
end of B.");
@ -2684,7 +2684,7 @@ bytes_pop(PyByteArrayObject *self, PyObject *args)
PyDoc_STRVAR(remove__doc__,
"B.remove(int) -> None\n\
\n\
Remove the first occurance of a value in B.");
Remove the first occurrence of a value in B.");
static PyObject *
bytes_remove(PyByteArrayObject *self, PyObject *arg)
{
@ -2735,7 +2735,8 @@ rstrip_helper(unsigned char *myptr, Py_ssize_t mysize,
PyDoc_STRVAR(strip__doc__,
"B.strip([bytes]) -> bytearray\n\
\n\
Strip leading and trailing bytes contained in the argument.\n\
Strip leading and trailing bytes contained in the argument\n\
and return the result as a new bytearray.\n\
If the argument is omitted, strip ASCII whitespace.");
static PyObject *
bytes_strip(PyByteArrayObject *self, PyObject *args)
@ -2771,7 +2772,8 @@ bytes_strip(PyByteArrayObject *self, PyObject *args)
PyDoc_STRVAR(lstrip__doc__,
"B.lstrip([bytes]) -> bytearray\n\
\n\
Strip leading bytes contained in the argument.\n\
Strip leading bytes contained in the argument\n\
and return the result as a new bytearray.\n\
If the argument is omitted, strip leading ASCII whitespace.");
static PyObject *
bytes_lstrip(PyByteArrayObject *self, PyObject *args)
@ -2804,7 +2806,8 @@ bytes_lstrip(PyByteArrayObject *self, PyObject *args)
PyDoc_STRVAR(rstrip__doc__,
"B.rstrip([bytes]) -> bytearray\n\
\n\
Strip trailing bytes contained in the argument.\n\
Strip trailing bytes contained in the argument\n\
and return the result as a new bytearray.\n\
If the argument is omitted, strip trailing ASCII whitespace.");
static PyObject *
bytes_rstrip(PyByteArrayObject *self, PyObject *args)
@ -2835,9 +2838,9 @@ bytes_rstrip(PyByteArrayObject *self, PyObject *args)
}
PyDoc_STRVAR(decode_doc,
"B.decode([encoding[, errors]]) -> unicode object.\n\
"B.decode([encoding[, errors]]) -> str\n\
\n\
Decodes B using the codec registered for encoding. encoding defaults\n\
Decode B using the codec registered for encoding. encoding defaults\n\
to the default encoding. errors may be given to set a different error\n\
handling scheme. Default is 'strict' meaning that encoding errors raise\n\
a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n\
@ -2860,7 +2863,7 @@ bytes_decode(PyObject *self, PyObject *args)
PyDoc_STRVAR(alloc_doc,
"B.__alloc__() -> int\n\
\n\
Returns the number of bytes actually allocated.");
Return the number of bytes actually allocated.");
static PyObject *
bytes_alloc(PyByteArrayObject *self)
@ -2869,9 +2872,10 @@ bytes_alloc(PyByteArrayObject *self)
}
PyDoc_STRVAR(join_doc,
"B.join(iterable_of_bytes) -> bytes\n\
"B.join(iterable_of_bytes) -> bytearray\n\
\n\
Concatenates any number of bytearray objects, with B in between each pair.");
Concatenate any number of bytes/bytearray objects, with B\n\
in between each pair, and return the result as a new bytearray.");
static PyObject *
bytes_join(PyByteArrayObject *self, PyObject *it)
@ -2944,7 +2948,7 @@ bytes_join(PyByteArrayObject *self, PyObject *it)
}
PyDoc_STRVAR(fromhex_doc,
"bytearray.fromhex(string) -> bytearray\n\
"bytearray.fromhex(string) -> bytearray (static method)\n\
\n\
Create a bytearray object from a string of hexadecimal numbers.\n\
Spaces between two numbers are accepted.\n\
@ -3121,10 +3125,10 @@ bytes_methods[] = {
};
PyDoc_STRVAR(bytes_doc,
"bytearray(iterable_of_ints) -> bytearray.\n\
bytearray(string, encoding[, errors]) -> bytearray.\n\
bytearray(bytes_or_bytearray) -> mutable copy of bytes_or_bytearray.\n\
bytearray(memory_view) -> bytearray.\n\
"bytearray(iterable_of_ints) -> bytearray\n\
bytearray(string, encoding[, errors]) -> bytearray\n\
bytearray(bytes_or_bytearray) -> mutable copy of bytes_or_bytearray\n\
bytearray(memory_view) -> bytearray\n\
\n\
Construct an mutable bytearray object from:\n\
- an iterable yielding integers in range(256)\n\
@ -3132,7 +3136,7 @@ Construct an mutable bytearray object from:\n\
- a bytes or a bytearray object\n\
- any object implementing the buffer API.\n\
\n\
bytearray(int) -> bytearray.\n\
bytearray(int) -> bytearray\n\
\n\
Construct a zero-initialized bytearray of the given length.");

View File

@ -1208,7 +1208,7 @@ string_split(PyBytesObject *self, PyObject *args)
PyDoc_STRVAR(partition__doc__,
"B.partition(sep) -> (head, sep, tail)\n\
\n\
Searches for the separator sep in B, and returns the part before it,\n\
Search for the separator sep in B, and return the part before it,\n\
the separator itself, and the part after it. If the separator is not\n\
found, returns B and two empty bytes objects.");
@ -1235,8 +1235,8 @@ string_partition(PyBytesObject *self, PyObject *sep_obj)
PyDoc_STRVAR(rpartition__doc__,
"B.rpartition(sep) -> (tail, sep, head)\n\
\n\
Searches for the separator sep in B, starting at the end of B,\n\
and returns the part before it, the separator itself, and the\n\
Search for the separator sep in B, starting at the end of B,\n\
and return the part before it, the separator itself, and the\n\
part after it. If the separator is not found, returns two empty\n\
bytes objects and B.");
@ -1423,7 +1423,7 @@ onError:
PyDoc_STRVAR(join__doc__,
"B.join(iterable_of_bytes) -> bytes\n\
\n\
Concatenates any number of bytes objects, with B in between each pair.\n\
Concatenate any number of bytes objects, with B in between each pair.\n\
Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'.");
static PyObject *
@ -2494,7 +2494,7 @@ replace(PyBytesObject *self,
}
if (to_len == 0) {
/* delete all occurances of 'from' string */
/* delete all occurrences of 'from' string */
if (from_len == 1) {
return replace_delete_single_character(
self, from_s[0], maxcount);
@ -2694,9 +2694,9 @@ string_endswith(PyBytesObject *self, PyObject *args)
PyDoc_STRVAR(decode__doc__,
"B.decode([encoding[, errors]]) -> object\n\
"B.decode([encoding[, errors]]) -> str\n\
\n\
Decodes S using the codec registered for encoding. encoding defaults\n\
Decode S using the codec registered for encoding. encoding defaults\n\
to the default encoding. errors may be given to set a different error\n\
handling scheme. Default is 'strict' meaning that encoding errors raise\n\
a UnicodeDecodeError. Other possible values are 'ignore' and 'replace'\n\
@ -3027,10 +3027,10 @@ str_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(string_doc,
"bytes(iterable_of_ints) -> bytes.\n\
"bytes(iterable_of_ints) -> bytes\n\
bytes(string, encoding[, errors]) -> bytes\n\
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer.\n\
bytes(memory_view) -> bytes.\n\
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer\n\
bytes(memory_view) -> bytes\n\
\n\
Construct an immutable array of bytes from:\n\
- an iterable yielding integers in range(256)\n\

View File

@ -6167,7 +6167,7 @@ nothing:
/* --- Unicode Object Methods --------------------------------------------- */
PyDoc_STRVAR(title__doc__,
"S.title() -> unicode\n\
"S.title() -> str\n\
\n\
Return a titlecased version of S, i.e. words start with title case\n\
characters, all remaining cased characters have lower case.");
@ -6179,7 +6179,7 @@ unicode_title(PyUnicodeObject *self)
}
PyDoc_STRVAR(capitalize__doc__,
"S.capitalize() -> unicode\n\
"S.capitalize() -> str\n\
\n\
Return a capitalized version of S, i.e. make the first character\n\
have upper case.");
@ -6192,7 +6192,7 @@ unicode_capitalize(PyUnicodeObject *self)
#if 0
PyDoc_STRVAR(capwords__doc__,
"S.capwords() -> unicode\n\
"S.capwords() -> str\n\
\n\
Apply .capitalize() to all words in S and return the result with\n\
normalized whitespace (all whitespace strings are replaced by ' ').");
@ -6256,7 +6256,7 @@ convert_uc(PyObject *obj, void *addr)
}
PyDoc_STRVAR(center__doc__,
"S.center(width[, fillchar]) -> unicode\n\
"S.center(width[, fillchar]) -> str\n\
\n\
Return S centered in a Unicode string of length width. Padding is\n\
done using the specified fill character (default is a space)");
@ -6601,9 +6601,9 @@ unicode_count(PyUnicodeObject *self, PyObject *args)
}
PyDoc_STRVAR(encode__doc__,
"S.encode([encoding[,errors]]) -> string or unicode\n\
"S.encode([encoding[, errors]]) -> bytes\n\
\n\
Encodes S using the codec registered for encoding. encoding defaults\n\
Encode S using the codec registered for encoding. encoding defaults\n\
to the default encoding. errors may be given to set a different error\n\
handling scheme. Default is 'strict' meaning that encoding errors raise\n\
a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and\n\
@ -6637,7 +6637,7 @@ unicode_encode(PyUnicodeObject *self, PyObject *args)
}
PyDoc_STRVAR(expandtabs__doc__,
"S.expandtabs([tabsize]) -> unicode\n\
"S.expandtabs([tabsize]) -> str\n\
\n\
Return a copy of S where all tab characters are expanded using spaces.\n\
If tabsize is not given, a tab size of 8 characters is assumed.");
@ -7152,7 +7152,7 @@ unicode_isidentifier(PyObject *self)
}
PyDoc_STRVAR(join__doc__,
"S.join(sequence) -> unicode\n\
"S.join(sequence) -> str\n\
\n\
Return a string which is the concatenation of the strings in the\n\
sequence. The separator between elements is S.");
@ -7170,7 +7170,7 @@ unicode_length(PyUnicodeObject *self)
}
PyDoc_STRVAR(ljust__doc__,
"S.ljust(width[, fillchar]) -> int\n\
"S.ljust(width[, fillchar]) -> str\n\
\n\
Return S left justified in a Unicode string of length width. Padding is\n\
done using the specified fill character (default is a space).");
@ -7193,7 +7193,7 @@ unicode_ljust(PyUnicodeObject *self, PyObject *args)
}
PyDoc_STRVAR(lower__doc__,
"S.lower() -> unicode\n\
"S.lower() -> str\n\
\n\
Return a copy of the string S converted to lowercase.");
@ -7302,7 +7302,7 @@ do_argstrip(PyUnicodeObject *self, int striptype, PyObject *args)
PyDoc_STRVAR(strip__doc__,
"S.strip([chars]) -> unicode\n\
"S.strip([chars]) -> str\n\
\n\
Return a copy of the string S with leading and trailing\n\
whitespace removed.\n\
@ -7320,7 +7320,7 @@ unicode_strip(PyUnicodeObject *self, PyObject *args)
PyDoc_STRVAR(lstrip__doc__,
"S.lstrip([chars]) -> unicode\n\
"S.lstrip([chars]) -> str\n\
\n\
Return a copy of the string S with leading whitespace removed.\n\
If chars is given and not None, remove characters in chars instead.\n\
@ -7337,7 +7337,7 @@ unicode_lstrip(PyUnicodeObject *self, PyObject *args)
PyDoc_STRVAR(rstrip__doc__,
"S.rstrip([chars]) -> unicode\n\
"S.rstrip([chars]) -> str\n\
\n\
Return a copy of the string S with trailing whitespace removed.\n\
If chars is given and not None, remove characters in chars instead.\n\
@ -7444,7 +7444,7 @@ PyObject *PyUnicode_Replace(PyObject *obj,
}
PyDoc_STRVAR(replace__doc__,
"S.replace (old, new[, maxsplit]) -> unicode\n\
"S.replace (old, new[, maxsplit]) -> str\n\
\n\
Return a copy of S with all occurrences of substring\n\
old replaced by new. If the optional argument maxsplit is\n\
@ -7678,7 +7678,7 @@ unicode_rindex(PyUnicodeObject *self, PyObject *args)
}
PyDoc_STRVAR(rjust__doc__,
"S.rjust(width[, fillchar]) -> unicode\n\
"S.rjust(width[, fillchar]) -> str\n\
\n\
Return S right justified in a Unicode string of length width. Padding is\n\
done using the specified fill character (default is a space).");
@ -7808,7 +7808,7 @@ PyUnicode_RPartition(PyObject *str_in, PyObject *sep_in)
PyDoc_STRVAR(partition__doc__,
"S.partition(sep) -> (head, sep, tail)\n\
\n\
Searches for the separator sep in S, and returns the part before it,\n\
Search for the separator sep in S, and return the part before it,\n\
the separator itself, and the part after it. If the separator is not\n\
found, returns S and two empty strings.");
@ -7821,7 +7821,7 @@ unicode_partition(PyUnicodeObject *self, PyObject *separator)
PyDoc_STRVAR(rpartition__doc__,
"S.rpartition(sep) -> (tail, sep, head)\n\
\n\
Searches for the separator sep in S, starting at the end of S, and returns\n\
Search for the separator sep in S, starting at the end of S, and return\n\
the part before it, the separator itself, and the part after it. If the\n\
separator is not found, returns two empty strings and S.");
@ -7912,7 +7912,7 @@ PyObject *unicode_str(PyObject *self)
}
PyDoc_STRVAR(swapcase__doc__,
"S.swapcase() -> unicode\n\
"S.swapcase() -> str\n\
\n\
Return a copy of S with uppercase characters converted to lowercase\n\
and vice versa.");
@ -8027,7 +8027,7 @@ unicode_maketrans(PyUnicodeObject *null, PyObject *args)
}
PyDoc_STRVAR(translate__doc__,
"S.translate(table) -> unicode\n\
"S.translate(table) -> str\n\
\n\
Return a copy of the string S, where all characters have been mapped\n\
through the given translation table, which must be a mapping of\n\
@ -8042,7 +8042,7 @@ unicode_translate(PyUnicodeObject *self, PyObject *table)
}
PyDoc_STRVAR(upper__doc__,
"S.upper() -> unicode\n\
"S.upper() -> str\n\
\n\
Return a copy of S converted to uppercase.");
@ -8053,7 +8053,7 @@ unicode_upper(PyUnicodeObject *self)
}
PyDoc_STRVAR(zfill__doc__,
"S.zfill(width) -> unicode\n\
"S.zfill(width) -> str\n\
\n\
Pad a numeric string x with zeros on the left, to fill a field\n\
of the specified width. The string x is never truncated.");
@ -8198,12 +8198,12 @@ unicode_endswith(PyUnicodeObject *self,
#include "stringlib/string_format.h"
PyDoc_STRVAR(format__doc__,
"S.format(*args, **kwargs) -> unicode\n\
"S.format(*args, **kwargs) -> str\n\
\n\
");
PyDoc_STRVAR(p_format__doc__,
"S.__format__(format_spec) -> unicode\n\
"S.__format__(format_spec) -> str\n\
\n\
");
@ -9108,7 +9108,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
PyDoc_STRVAR(unicode_doc,
"str(string [, encoding[, errors]]) -> object\n\
"str(string[, encoding[, errors]]) -> str\n\
\n\
Create a new string object from the given encoded string.\n\
encoding defaults to the current default string encoding.\n\