Mercurial > cpython-lru_cache-weakref
comparison Modules/arraymodule.c @ 11522:cbf58cd0bb57 legacy-trunk
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.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Fri, 03 Dec 1999 17:15:30 +0000 |
| parents | 0061ca4865d7 |
| children | 5e6e9e893acd |
comparison
equal
deleted
inserted
replaced
| 11521:ba07fff72511 | 11522:cbf58cd0bb57 |
|---|---|
| 757 arrayobject *self; | 757 arrayobject *self; |
| 758 PyObject *args; | 758 PyObject *args; |
| 759 { | 759 { |
| 760 char *p; | 760 char *p; |
| 761 int i; | 761 int i; |
| 762 | |
| 763 if (!PyArg_ParseTuple(args, ":byteswap")) | |
| 764 return NULL; | |
| 765 | |
| 762 switch (self->ob_descr->itemsize) { | 766 switch (self->ob_descr->itemsize) { |
| 763 case 1: | 767 case 1: |
| 764 break; | 768 break; |
| 765 case 2: | 769 case 2: |
| 766 for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 2) { | 770 for (p = self->ob_item, i = self->ob_size; --i >= 0; p += 2) { |
| 803 Py_INCREF(Py_None); | 807 Py_INCREF(Py_None); |
| 804 return Py_None; | 808 return Py_None; |
| 805 } | 809 } |
| 806 | 810 |
| 807 static char byteswap_doc [] = | 811 static char byteswap_doc [] = |
| 808 "byteswap(x)\n\ | 812 "byteswap()\n\ |
| 809 \n\ | 813 \n\ |
| 810 Byteswap all items of the array. This is only supported for integer\n\ | 814 Byteswap all items of the array. If the items in the array are not 1, 2,\n\ |
| 811 values of x, which determines the size of the blocks swapped."; | 815 4, or 8 bytes in size, RuntimeError is raised."; |
| 812 | 816 |
| 813 static PyObject * | 817 static PyObject * |
| 814 array_reverse(self, args) | 818 array_reverse(self, args) |
| 815 arrayobject *self; | 819 arrayobject *self; |
| 816 PyObject *args; | 820 PyObject *args; |
| 1137 representation."; | 1141 representation."; |
| 1138 | 1142 |
| 1139 PyMethodDef array_methods[] = { | 1143 PyMethodDef array_methods[] = { |
| 1140 {"append", (PyCFunction)array_append, 0, append_doc}, | 1144 {"append", (PyCFunction)array_append, 0, append_doc}, |
| 1141 {"buffer_info", (PyCFunction)array_buffer_info, 0, buffer_info_doc}, | 1145 {"buffer_info", (PyCFunction)array_buffer_info, 0, buffer_info_doc}, |
| 1142 {"byteswap", (PyCFunction)array_byteswap, 0, byteswap_doc}, | 1146 {"byteswap", (PyCFunction)array_byteswap, METH_VARARGS, |
| 1147 byteswap_doc}, | |
| 1143 /* {"count", (method)array_count},*/ | 1148 /* {"count", (method)array_count},*/ |
| 1144 {"fromfile", (PyCFunction)array_fromfile, 0, fromfile_doc}, | 1149 {"fromfile", (PyCFunction)array_fromfile, 0, fromfile_doc}, |
| 1145 {"fromlist", (PyCFunction)array_fromlist, 0, fromlist_doc}, | 1150 {"fromlist", (PyCFunction)array_fromlist, 0, fromlist_doc}, |
| 1146 {"fromstring", (PyCFunction)array_fromstring, 0, fromstring_doc}, | 1151 {"fromstring", (PyCFunction)array_fromstring, 0, fromstring_doc}, |
| 1147 /* {"index", (method)array_index},*/ | 1152 /* {"index", (method)array_index},*/ |
