Comment 0 for bug 457979

Revision history for this message
Matt Nordhoff (mnordhoff) wrote :

Lookie:

    if (size < 0) {
        PyErr_BadInternalCall();
        return NULL;
    }

    if (size < 0 || size > 255) {
        /* Too big or too small */
        PyErr_SetString(PyExc_ValueError, "StaticTuple(...)"
            " takes from 0 to 255 items");
        return NULL;
    }

Not only is this redundant, but PyErr_BadInternalCall() throws a TypeError, meaning two different exception classes are used.

ISTM StaticTuple_New should throw a ValueError, since you do StaticTuple_New(length), and StaticTuple_new_constructor should throw a TypeError, since you do StaticTuple(foo, bar, baz).

FYI, the Python version of StaticTuple throws a ValueError when it's either <0 or >255. IMO, that should be a TypeError, same as StaticTuple_new_constructor.