[issue17445] Handle bytes comparisons in difflib.Differ

Terry J. Reedy report at bugs.python.org
Tue Mar 19 23:51:21 CET 2013


Terry J. Reedy added the comment:

The surrogate escape approach embodies the 3.x recommendation:
decode bytes to strings, manipulate strings, encode strings to bytes.
It also makes it possible to wrap the existing context/unified_diff functions, without touching them, with a simple 12 line function. Function bytes_diff avoids the complexities of mixing and unmixing strings and bytes that remain in Greg's latest patch.

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. Next upload to pypi to make it available to all 3.1-3.3 users. Then, after some minimal field testing, add the utility wrapper function to 3.4 difflib.  These steps would make moot for difflib the sub-issue of whether the 3.x design is a bug fixable in bugfix releases. We could even add a reference to the pypi module in the 3.2 and 3.3 docs.

----------
Added file: http://bugs.python.org/file29493/bytes_diff.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17445>
_______________________________________


More information about the Python-bugs-list mailing list