[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Tim Peters
Tim Peters added the comment: It's probably OK, but there's no "pure win" to be had here. There's generally more than one way to convert one string to another, and what "looks right" to humans depends a whole lot on context. For example, consider these strings: "private Thread

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Jason R. Coombs
Jason R. Coombs added the comment: Nice insight Tim. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: Thanks for the explanation. This seems to give the desired diff with charjunk=None passed to multiline string comparison helper. I am not sure how useful it would be to pass it to sequence and dict comparison that also use ndiff. I can open a PR if

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Tim Peters
Tim Peters added the comment: difflib generally synchs on the longest contiguous matching subsequence that doesn't contain a "junk" element. By default, `ndiff()`'s optional `charjunk` argument considers blanks and tabs to be junk characters. In the strings: "drwxrwxr-x 2 2000 2000\n"

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: I am not sure this is a duplicate since the other issue was about newline at the end of strings. This is about the diff being little irrelevant even with newline in the end for strings. Sample program where change in 5th character gives the

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Jason R. Coombs
Jason R. Coombs added the comment: I don't think so, because the issue happens on a single line diff... although it's plausible there's a common-mode fix. -- ___ Python tracker

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Chris Jerdonek
Chris Jerdonek added the comment: Is this a duplicate of issue24780? -- nosy: +chris.jerdonek ___ Python tracker ___ ___

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: I have tried with different places where only '-' and 'w' differ. They seemed to produce correct diff except for this once case where the diff was confusing. -- nosy: +tim.peters type: -> behavior versions: +Python 2.7, Python 3.7, Python

[issue35955] difflib reports incorrect location of mismatch

2019-02-11 Thread Jason R. Coombs
Jason R. Coombs added the comment: I'm re-opening this issue as it does seem to apply stdlib (difflib.ndiff), which is why I encountered it both in unittest and pytest. Thanks xtreak for the distilled example. -- resolution: third party -> stage: resolved -> status: closed -> open