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 serhiy.storchaka
Recipients mark.dickinson, serhiy.storchaka
Date 2018-09-14.10:13:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1536920030.35.0.956365154283.issue34676@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-09-14 10:13:50serhiy.storchakasetrecipients: + serhiy.storchaka, mark.dickinson
2018-09-14 10:13:50serhiy.storchakasetmessageid: <1536920030.35.0.956365154283.issue34676@psf.upfronthosting.co.za>
2018-09-14 10:13:50serhiy.storchakalinkissue34676 messages
2018-09-14 10:13:50serhiy.storchakacreate