Message109129
| Author |
belopolsky |
| Recipients |
amaury.forgeotdarc, belopolsky, brett.cannon, brian.curtin, daniel.urban, lemburg, mark.dickinson, pitrou, r.david.murray, rhettinger, techtonik, tim.peters, vstinner |
| Date |
2010年07月02日.20:41:39 |
| SpamBayes Score |
6.613522e-05 |
| Marked as misclassified |
No |
| Message-id |
<1278103301.45.0.452040042057.issue7989@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> 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 |
|
History
|
|---|
| 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 |
|