Message109129
> I am talking specifically about this kind of assert:
>
> assert 1 <= month <= 12, 'month must be in 1..12'
>
> I think it should be replaced with:
>
> if month < 1 or month > 12:
> raise ValueError('month must be in 1..12')
I reviewed the asserts. Value range checking asserts appear in non-public functions which are not called with out-of-range values by the module code. Therefore they can only be triggered if there is a bug in the future version of datetime.py. This is expressly what asserts are for.
There is another type of asserts that should be either removed or modified:
assert daysecondswhole == int(daysecondswhole) # can't overflow
Since int is long in 3.x, this assert does not check anything. We can replace this with
assert daysecondswhole.bit_length() <= 32 |
|
Date |
User |
Action |
Args |
2010-07-02 20:41:41 | belopolsky | set | recipients:
+ belopolsky, lemburg, tim.peters, brett.cannon, rhettinger, amaury.forgeotdarc, mark.dickinson, pitrou, vstinner, techtonik, r.david.murray, brian.curtin, daniel.urban |
2010-07-02 20:41:41 | belopolsky | set | messageid: <1278103301.45.0.452040042057.issue7989@psf.upfronthosting.co.za> |
2010-07-02 20:41:40 | belopolsky | link | issue7989 messages |
2010-07-02 20:41:39 | belopolsky | create | |
|