]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
In b_setitem(), instead of the platform dependent CHAR_MIN and
authorGuido van Rossum <guido@python.org>
Sat, 1 Jul 2000 00:38:19 +0000 (00:38 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 1 Jul 2000 00:38:19 +0000 (00:38 +0000)
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!

Modules/arraymodule.c

index ba5105cc0c0861f843ba755c4934bda358622f0a..7bc7e738bd7008a5e2da2a2a349229bc9e5b2add 100644 (file)
@@ -99,12 +99,12 @@ b_setitem(ap, i, v)
           the overflow checking */
        if (!PyArg_Parse(v, "h;array item must be integer", &x))
                return -1;
-       else if (x < CHAR_MIN) {
+       else if (x < -128) {
                PyErr_SetString(PyExc_OverflowError,
                        "signed char is less than minimum");
                return -1;
        }
-       else if (x > CHAR_MAX) {
+       else if (x > 127) {
                PyErr_SetString(PyExc_OverflowError,
                        "signed char is greater than maximum");
                return -1;