This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: ndiff reports incorrect location when diff strings contain tabs
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: Anthony Sottile, rhettinger, tim.peters
Priority: normal Keywords: patch

Created on 2019-08-10 18:59 by Anthony Sottile, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15201 merged Anthony Sottile, 2019-08-10 19:36
PR 15365 merged miss-islington, 2019-08-21 19:02
Messages (3)
msg349353 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-08-10 18:59
Here's an example

from difflib import ndiff

def main():
    x = '\tx\t=\ty\n\t \t \t^'
    y = '\tx\t=\ty\n\t \t \t^\n'
        line.rstrip('\n') for line in
        ndiff(x.splitlines(True), y.splitlines(True)))

if __name__ == '__main__':

Current output:

$ python3.8
  	x	=	y
- 	 	 	^
+ 	 	 	^
? 	     +

Expected output:

$ ./python
  	x	=	y
- 	 	 	^
+ 	 	 	^
? 	 	 	 +

Found this while implementing a similar thing for flake8 here: and while debugging with pytest
msg349354 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-08-10 19:49
This seems like a reasonable suggestion to me.  Am not sure whether it should be backported.

Tim, what do you think?
msg349391 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-08-11 14:11
That's actually a good point, I don't think this should land in python3.7 since it changes outuput -- I'm removing that from the versions (though the bug does affect every version I have access to)
Date User Action Args
2022-04-11 14:59:18adminsetgithub: 81991
2019-08-21 20:26:10tim.peterssetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-08-21 19:02:54miss-islingtonsetpull_requests: + pull_request15075
2019-08-11 14:11:54Anthony Sottilesetmessages: + msg349391
versions: - Python 3.7
2019-08-10 19:49:27rhettingersetnosy: + rhettinger, tim.peters
messages: + msg349354

assignee: tim.peters
components: + Library (Lib)
2019-08-10 19:36:09Anthony Sottilesetkeywords: + patch
stage: patch review
pull_requests: + pull_request14930
2019-08-10 18:59:04Anthony Sottilecreate