[issue37810] ndiff reports incorrect location when diff strings contain tabs

Anthony Sottile report at bugs.python.org
Sat Aug 10 14:59:04 EDT 2019


New submission from Anthony Sottile <asottile at umich.edu>:

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'
    print('\n'.join(
        line.rstrip('\n') for line in
        ndiff(x.splitlines(True), y.splitlines(True)))
    )


if __name__ == '__main__':
    exit(main())


Current output:

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


Expected output:

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


Found this while implementing a similar thing for flake8 here: https://gitlab.com/pycqa/flake8/merge_requests/339 and while debugging with pytest

----------
messages: 349353
nosy: Anthony Sottile
priority: normal
severity: normal
status: open
title: ndiff reports incorrect location when diff strings contain tabs
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37810>
_______________________________________


More information about the Python-bugs-list mailing list