Message325341
It is documented that divmod() returns a pair of numbers, but the implementation doesn't enforce this. Actually divmod() just returns the result of __divmod__() or __rdivmod__() without checking it. PyNumber_Divmod() is documented as the C equivalent of divmod(). But since it returns a 2-tuple in all implemented cases, the user code can expect that it always return a 2-tuple. This can lead to hidden bugs similar to issue31577.
I think there are no reasons of returning anything except a 2-tuple from divmod(). Forcing this conditions can save third-party code from crashes. The following PR make divmod() and PyNumber_Divmod() always returning a 2-tuple. |
|
Date |
User |
Action |
Args |
2018-09-14 10:13:50 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, mark.dickinson |
2018-09-14 10:13:50 | serhiy.storchaka | set | messageid: <1536920030.35.0.956365154283.issue34676@psf.upfronthosting.co.za> |
2018-09-14 10:13:50 | serhiy.storchaka | link | issue34676 messages |
2018-09-14 10:13:50 | serhiy.storchaka | create | |
|