[issue42660] _zoneinfo.c incorrectly checks bounds of `day` variable in calenderrule_new
Ammar Askar
report at bugs.python.org
Wed Dec 16 11:48:22 EST 2020
Ammar Askar <ammar at ammaraskar.com> added the comment:
> Some compilers complain about checking `day < 0`, because `day` is an unsigned type
Just my two cents, this isn't just "some compilers". Everything from gcc, msvc, C# to the rust compiler complain about this sort of code. As they should, this is effectively dead code.
I think the more pragmatic way to enforce and document this assumption would be to have a unit test that actually checks that the constructor fails with "negative" days. It'll continue to fail right now as its interpretation as an unsigned int will be large and it will start failing if someone changes this to a signed type.
----------
nosy: +ammar2
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42660>
_______________________________________
More information about the Python-bugs-list
mailing list