Greg Ward added the comment: > I recommend the following: replace the simple test in the attached > bytes_diff.py with > Greg's unittest-based tests and adjust the __name__ == '__main__' incantation > accordingly.
Latest patch, following Terry's suggestion: http://hg.gerg.ca/cpython/rev/6718d54cf9eb Pro: - does not touch unified_diff() or context_diff(), just adds a new function - no question that this is a new feature, so no debate about what branch to commit on - forces caller to know exactly what they are dealing with, strings or bytes Con: - not a bug fix, so 3.3 users won't get it ... but they can just copy the implementation of diff_bytes() (or, as Terry suggests, it could live on PyPI) - has explicit isinstance() checks (for a good reason: see the comments) - also has more Pythonic "raise TypeError if s.decode raised AttributeError", which is friendlier to duck typing but inconsistent with the isinstance() checks used elsewhere in the patch Overall I'm fairly happy with this. Not too thrilled with the explicit type checks; suggestions welcome. Regarding Terry's suggestion of putting diff_bytes() on PyPI: meh. If the only project that needs this is Mercurial, that would be pointless. Mercurial doesn't have PyPI dependencies, and that is unlikely to change. This might be one of those rare cases where copying the code is easier than depending on it. ---------- assignee: -> gward _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17445> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com