Merge lp:~mnordhoff/bzr/st-size-exceptions into lp:bzr
Proposed by
Matt Nordhoff
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | John A Meinel | ||||
Approved revision: | not available | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~mnordhoff/bzr/st-size-exceptions | ||||
Merge into: | lp:bzr | ||||
Diff against target: |
67 lines (+13/-9) 3 files modified
bzrlib/_static_tuple_c.c (+8/-4) bzrlib/_static_tuple_py.py (+3/-3) bzrlib/tests/test__static_tuple.py (+2/-2) |
||||
To merge this branch: | bzr merge lp:~mnordhoff/bzr/st-size-exceptions | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John A Meinel | Approve | ||
Review via email: mp+13770@code.launchpad.net |
To post a comment you must log in.
Updating diff...
An updated diff will be available in a few minutes. Reload to see the changes.
This makes the changes I suggested in bug #457979:
> Lookie: alCall( ); (PyExc_ ValueError, "StaticTuple(...)" alCall( ) throws a New(length) , and StaticTuple_ new_constructor should throw a new_constructor .
>
> if (size < 0) {
> PyErr_BadIntern
> return NULL;
> }
>
> if (size < 0 || size > 255) {
> /* Too big or too small */
> PyErr_SetString
> " takes from 0 to 255 items");
> return NULL;
> }
>
> Not only is this redundant, but PyErr_BadIntern
> TypeError, meaning two different exception classes are used.
>
> ISTM StaticTuple_New should throw a ValueError, since you do
> StaticTuple_
> 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_
* bzrlib/ _static_ tuple_c. c: new_constructor ): Raise a TypeError when this happens, instead of letting StaticTuple_New raise its ValueError.
(StaticTuple_New): Raise a ValueError when size <0, just like when it's >255.
(StaticTuple_
* bzrlib/ _static_ tuple_py. py: __init_ _): Change the ValueError to a TypeError as well. Move the length check before the type checks, to match StaticTuple_ new_constructor , and copy over its error message, since I like it better and it doesn't refer to "key bits".
(StaticTuple.
* bzrlib/ tests/test_ _static_ tuple.py: e.test_ create_ bad_args) : Make the relevant type adjustments.
(TestStaticTupl