[Python-bugs-list] [Bug #113960] Problems with reverse() in the array module
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 9 Sep 2000 13:20:59 -0700
Bug #113960, was updated on 2000-Sep-09 13:20
Here is a current snapshot of the bug.
Project: Python
Category: None
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: Problems with reverse() in the array module
Details: When I was using Python-2.0b1, reverse() for arrays was acting funny for me:
>>> import array
>>> bob = array.array('c', 'a string')
>>> bob.reverse()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: <array>.reverse requires exactly 0 arguments
But, I didn't pass it any arguments :-). When I looked at the code I came up with the following fix:
*** arraymodule.c.orig Fri Sep 1 19:29:26 2000
--- arraymodule.c Sat Sep 9 16:04:16 2000
***************
*** 935,945 ****
register char *p, *q;
char tmp[sizeof(double)]; /* Assume that's the max item size */
! if (args != NULL) {
! PyErr_SetString(PyExc_TypeError,
! "<array>.reverse requires exactly 0 arguments");
! return NULL;
! }
if (self->ob_size > 1) {
for (p = self->ob_item,
--- 935,942 ----
register char *p, *q;
char tmp[sizeof(double)]; /* Assume that's the max item size */
! if (!PyArg_ParseTuple(args, ":reverse"))
! return NULL;
if (self->ob_size > 1) {
for (p = self->ob_item,
Reverse seems to work properly with this:
>>> import array
>>> bob = array.array('c', 'a string')
>>> bob.reverse()
>>> print bob
array('c', 'gnirts a')
and the error message for passing argument seems reasonable:
>>> bob.reverse('spam')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: reverse requires exactly 0 arguments; 1 given
I'm really not an expert on any of this, but I hope the report is useful. Thanks for listening.
Brad
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=113960&group_id=5470