[issue2142] difflib.unified_diff(...) produces invalid patches
Mark Dickinson
report at bugs.python.org
Fri May 14 11:13:57 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
I think it's arguable whether this is a bug or not. There's no official specification for the unified diff format that I can find anywhere; the GNU description at
http://www.gnu.org/software/hello/manual/diff/Detailed-Unified.html#Detailed-Unified
doesn't mention this detail. The '\ No newline at end of file' is actually unnecessary for these Python functions, since they operate on lists and produce a generator, so it would be needless complication. And changing this might break existing Python code that manually parses the output of unified_diff or context_diff and doesn't know what to do with a leading '\' character. (Does such Python code exist? I don't know.)
I'd suggest adding a keyword argument to the unified_diff and context_diff functions to enable this feature, leaving it disabled by default.
----------
nosy: +tim_one
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2142>
_______________________________________
More information about the Python-bugs-list
mailing list