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 p-ganssle
Recipients mark.dickinson, p-ganssle, rhettinger, serhiy.storchaka, xtreak, zach.ware
Date 2018-09-17.13:37:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537191462.35.0.956365154283.issue34676@psf.upfronthosting.co.za>
In-reply-to
Content
@Serhiy I like the "convert to a tuple" idea before returning *better*, though I think I'd prefer to just check that it's tuple-like, something like:

    if not all(hasattr(return_val, attr) for attr in ['__getitem__', '__len__']) or len(return_val) != 2:
        warnings.warn("divmod must return a Sequence of length 2. " +
                      "This will be an exception in Python 3.9+",
                      Deprecationwarning)

Or some similar equivalent to `if not isinstance(return_val, collections.abc.Sequence) or len(return_val) != 2`.

That said, the PR seems to have already run into an issue, which is that `unittest.mock.MagicMock` returns a `unittest.mock.MagicMock` from `divmod`, which is not a 2-tuple.
History
Date User Action Args
2018-09-17 13:37:42p-gansslesetrecipients: + p-ganssle, rhettinger, mark.dickinson, zach.ware, serhiy.storchaka, xtreak
2018-09-17 13:37:42p-gansslesetmessageid: <1537191462.35.0.956365154283.issue34676@psf.upfronthosting.co.za>
2018-09-17 13:37:42p-gansslelinkissue34676 messages
2018-09-17 13:37:42p-gansslecreate