Paul Ganssle <p.gans...@gmail.com> added the comment:
@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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34676> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com