Issue #8973: Improve struct module docstrings.

This commit is contained in:
Mark Dickinson 2010-06-12 15:43:45 +00:00
parent d80a8eefe6
commit aacfa95d2e
1 changed files with 37 additions and 22 deletions

View File

@ -1398,9 +1398,9 @@ fail:
PyDoc_STRVAR(s_unpack__doc__, PyDoc_STRVAR(s_unpack__doc__,
"S.unpack(buffer) -> (v1, v2, ...)\n\ "S.unpack(buffer) -> (v1, v2, ...)\n\
\n\ \n\
Return tuple containing values unpacked according to this Struct's format.\n\ Return a tuple containing values unpacked according to the format\n\
Requires len(buffer) == self.size. See struct.__doc__ for more on format\n\ string S.format. Requires len(buffer) == S.size. See help(struct)\n\
strings."); for more on format strings.");
static PyObject * static PyObject *
s_unpack(PyObject *self, PyObject *input) s_unpack(PyObject *self, PyObject *input)
@ -1426,12 +1426,11 @@ s_unpack(PyObject *self, PyObject *input)
} }
PyDoc_STRVAR(s_unpack_from__doc__, PyDoc_STRVAR(s_unpack_from__doc__,
"S.unpack_from(buffer[, offset]) -> (v1, v2, ...)\n\ "S.unpack_from(buffer[, offset=0]) -> (v1, v2, ...)\n\
\n\ \n\
Return tuple containing values unpacked according to this Struct's format.\n\ Return a tuple containing values unpacked according to the format\n\
Unlike unpack, unpack_from can unpack values from any object supporting\n\ string S.format. Requires len(buffer[offset:]) >= S.size. See\n\
the buffer API, not just str. Requires len(buffer[offset:]) >= self.size.\n\ help(struct) for more on format strings.");
See struct.__doc__ for more on format strings.");
static PyObject * static PyObject *
s_unpack_from(PyObject *self, PyObject *args, PyObject *kwds) s_unpack_from(PyObject *self, PyObject *args, PyObject *kwds)
@ -1566,8 +1565,9 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
PyDoc_STRVAR(s_pack__doc__, PyDoc_STRVAR(s_pack__doc__,
"S.pack(v1, v2, ...) -> bytes\n\ "S.pack(v1, v2, ...) -> bytes\n\
\n\ \n\
Return a bytes containing values v1, v2, ... packed according to this\n\ Return a bytes object containing values v1, v2, ... packed according\n\
Struct's format. See struct.__doc__ for more on format strings."); to the format string S.format. See help(struct) for more on format\n\
strings.");
static PyObject * static PyObject *
s_pack(PyObject *self, PyObject *args) s_pack(PyObject *self, PyObject *args)
@ -1603,10 +1603,10 @@ s_pack(PyObject *self, PyObject *args)
PyDoc_STRVAR(s_pack_into__doc__, PyDoc_STRVAR(s_pack_into__doc__,
"S.pack_into(buffer, offset, v1, v2, ...)\n\ "S.pack_into(buffer, offset, v1, v2, ...)\n\
\n\ \n\
Pack the values v1, v2, ... according to this Struct's format, write \n\ Pack the values v1, v2, ... according to the format string S.format\n\
the packed bytes into the writable buffer buf starting at offset. Note\n\ and write the packed bytes into the writable buffer buf starting at\n\
that the offset is not an optional argument. See struct.__doc__ for \n\ offset. Note that the offset is not an optional argument. See\n\
more on format strings."); help(struct) for more on format strings.");
static PyObject * static PyObject *
s_pack_into(PyObject *self, PyObject *args) s_pack_into(PyObject *self, PyObject *args)
@ -1781,7 +1781,9 @@ clearcache(PyObject *self)
} }
PyDoc_STRVAR(calcsize_doc, PyDoc_STRVAR(calcsize_doc,
"Return size of C struct described by format string fmt."); "calcsize(fmt) -> integer\n\
\n\
Return size in bytes of the struct described by the format string fmt.");
static PyObject * static PyObject *
calcsize(PyObject *self, PyObject *fmt) calcsize(PyObject *self, PyObject *fmt)
@ -1796,7 +1798,10 @@ calcsize(PyObject *self, PyObject *fmt)
} }
PyDoc_STRVAR(pack_doc, PyDoc_STRVAR(pack_doc,
"Return bytes containing values v1, v2, ... packed according to fmt."); "pack(fmt, v1, v2, ...) -> bytes\n\
\n\
Return a bytes object containing values v1, v2, ... packed according to\n\
the format string fmt. See help(struct) for more on format strings.");
static PyObject * static PyObject *
pack(PyObject *self, PyObject *args) pack(PyObject *self, PyObject *args)
@ -1825,8 +1830,12 @@ pack(PyObject *self, PyObject *args)
} }
PyDoc_STRVAR(pack_into_doc, PyDoc_STRVAR(pack_into_doc,
"Pack the values v1, v2, ... according to fmt.\n\ "pack_into(fmt, buffer, offset, v1, v2, ...)\n\
Write the packed bytes into the writable buffer buf starting at offset."); \n\
Pack the values v1, v2, ... according to the format string fmt and write\n\
the packed bytes into the writable buffer buf starting at offset. Note\n\
that the offset is not an optional argument. See help(struct) for more\n\
on format strings.");
static PyObject * static PyObject *
pack_into(PyObject *self, PyObject *args) pack_into(PyObject *self, PyObject *args)
@ -1855,8 +1864,11 @@ pack_into(PyObject *self, PyObject *args)
} }
PyDoc_STRVAR(unpack_doc, PyDoc_STRVAR(unpack_doc,
"Unpack the bytes containing packed C structure data, according to fmt.\n\ "unpack(fmt, buffer) -> (v1, v2, ...)\n\
Requires len(bytes) == calcsize(fmt)."); \n\
Return a tuple containing values unpacked according to the format string\n\
fmt. Requires len(buffer) == calcsize(fmt). See help(struct) for more\n\
on format strings.");
static PyObject * static PyObject *
unpack(PyObject *self, PyObject *args) unpack(PyObject *self, PyObject *args)
@ -1875,8 +1887,11 @@ unpack(PyObject *self, PyObject *args)
} }
PyDoc_STRVAR(unpack_from_doc, PyDoc_STRVAR(unpack_from_doc,
"Unpack the buffer, containing packed C structure data, according to\n\ "unpack_from(fmt, buffer[, offset=0]) -> (v1, v2, ...)\n\
fmt, starting at offset. Requires len(buffer[offset:]) >= calcsize(fmt)."); \n\
Return a tuple containing values unpacked according to the format string\n\
fmt. Requires len(buffer[offset:]) >= calcsize(fmt). See help(struct)\n\
for more on format strings.");
static PyObject * static PyObject *
unpack_from(PyObject *self, PyObject *args, PyObject *kwds) unpack_from(PyObject *self, PyObject *args, PyObject *kwds)