2009-10-22 08:13:24 |
Matt Nordhoff |
description |
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. |
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) (currently it lets StaticTuple_New handle throw the error).
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.
|
|