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.
Lookie:
if (size < 0) {
PyErr_ BadInternalCall ();
return NULL;
}
if (size < 0 || size > 255) {
PyErr_ SetString( PyExc_ValueErro r, "StaticTuple(...)"
/* Too big or too small */
" takes from 0 to 255 items");
return NULL;
}
Not only is this redundant, but PyErr_BadIntern alCall( ) 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 .