diff options
author | Fred Drake <fdrake@acm.org> | 1999-12-03 17:15:30 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-12-03 17:15:30 (GMT) |
commit | bf272983643776e9842cad6d1885f1b92f5eb67f (patch) | |
tree | 3a3e54066800aadb7c1dbbcabcc9f4e350a8b40f /Modules | |
parent | 631e6a0c070810b064c48ff6cf777ebb0276f038 (diff) | |
download | cpython-bf272983643776e9842cad6d1885f1b92f5eb67f.zip cpython-bf272983643776e9842cad6d1885f1b92f5eb67f.tar.gz cpython-bf272983643776e9842cad6d1885f1b92f5eb67f.tar.bz2 |
Correct the docstring for byteswap(); error noted by Bernhard Reiter
<bernhard@uwm.edu>.
Added a check that no parameters were passed to byteswap(); previously
allowed any parameters you happened to pass.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/arraymodule.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 6b47e0c..fc7bf07 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -759,6 +759,10 @@ array_byteswap(self, args) { char *p; int i; + + if (!PyArg_ParseTuple(args, ":byteswap")) + return NULL; + switch (self->ob_descr->itemsize) { case 1: break; @@ -805,10 +809,10 @@ array_byteswap(self, args) } static char byteswap_doc [] = -"byteswap(x)\n\ +"byteswap()\n\ \n\ -Byteswap all items of the array. This is only supported for integer\n\ -values of x, which determines the size of the blocks swapped."; +Byteswap all items of the array. If the items in the array are not 1, 2,\n\ +4, or 8 bytes in size, RuntimeError is raised."; static PyObject * array_reverse(self, args) @@ -1139,7 +1143,8 @@ representation."; PyMethodDef array_methods[] = { {"append", (PyCFunction)array_append, 0, append_doc}, {"buffer_info", (PyCFunction)array_buffer_info, 0, buffer_info_doc}, - {"byteswap", (PyCFunction)array_byteswap, 0, byteswap_doc}, + {"byteswap", (PyCFunction)array_byteswap, METH_VARARGS, + byteswap_doc}, /* {"count", (method)array_count},*/ {"fromfile", (PyCFunction)array_fromfile, 0, fromfile_doc}, {"fromlist", (PyCFunction)array_fromlist, 0, fromlist_doc}, |