[Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.44,2.45
Guido van Rossum
python-dev@python.org
Fri, 30 Jun 2000 17:38:22 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv16905
Modified Files:
arraymodule.c
Log Message:
In b_setitem(), instead of the platform dependent CHAR_MIN and
CHAR_MAX, use hardcoded -128 and 127. This may seem strange, unless
you realize that we're talking about signed bytes here! Bytes are
always 8 bits and 2's complement. CHAR_MIN and CHAR_MAX are
properties of the char data type, which is guaranteed to hold at least
8 bits anyway.
Otherwise you'd get failing tests on platforms where unsigned char is
the default (e.g. AIX).
Thanks, Vladimir Marangozov, for finding this nit!
Index: arraymodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v
retrieving revision 2.44
retrieving revision 2.45
diff -C2 -r2.44 -r2.45
*** arraymodule.c 2000/06/30 23:58:05 2.44
--- arraymodule.c 2000/07/01 00:38:19 2.45
***************
*** 100,109 ****
if (!PyArg_Parse(v, "h;array item must be integer", &x))
return -1;
! else if (x < CHAR_MIN) {
PyErr_SetString(PyExc_OverflowError,
"signed char is less than minimum");
return -1;
}
! else if (x > CHAR_MAX) {
PyErr_SetString(PyExc_OverflowError,
"signed char is greater than maximum");
--- 100,109 ----
if (!PyArg_Parse(v, "h;array item must be integer", &x))
return -1;
! else if (x < -128) {
PyErr_SetString(PyExc_OverflowError,
"signed char is less than minimum");
return -1;
}
! else if (x > 127) {
PyErr_SetString(PyExc_OverflowError,
"signed char is greater than maximum");