Alexander Belopolsky <[email protected]> added the comment:
> 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
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7989>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com