This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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.61352e-05
Marked as misclassified No
Message-id <>
> 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  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:41belopolskysetrecipients: + 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:41belopolskysetmessageid: <>
2010-07-02 20:41:40belopolskylinkissue7989 messages
2010-07-02 20:41:39belopolskycreate