[New-bugs-announce] [issue27913] Difflib.ndiff (Problem on identification of changes as Diff Style)

vincenzo gisondi report at bugs.python.org
Wed Aug 31 10:37:05 EDT 2016


New submission from vincenzo gisondi:

I found an anomaly on identification of changes as Diff Style (^).

There are the tests that i done:

1) First Test (only one character is different)

>>> a = "Hello Vincenzo\n".splitlines(1)
>>> b = "Hello Vincenza\n".splitlines(1)
>>> a
['Hello Vincenzo\n']
>>> b
['Hello Vincenza\n']
>>> diff = difflib.ndiff(a,b)
>>> print(''.join(diff))
- Hello Vincenzo
?              ^
+ Hello Vincenza
?              ^


2) Second Test (two characters are differents)

>>> a = "Hello Vincenzo\n".splitlines(1)
>>> b = "Hello Vincensa\n".splitlines(1)
>>> a
['Hello Vincenzo\n']
>>> b
['Hello Vincensa\n']
>>> diff = difflib.ndiff(a,b)
>>> print(''.join(diff))
- Hello Vincenzo
?             ^^
+ Hello Vincensa
?             ^^

3) Third Test (three characters are differents)

>>> a = "Hello Vincenzo\n".splitlines(1)
>>> b = "Helto Bincenza\n".splitlines(1)
>>> a
['Hello Vincenzo\n']
>>> b
['Helto Bincenza\n']
>>> diff = difflib.ndiff(a,b)
>>> print(''.join(diff))
- Hello Vincenzo
?    ^  ^      ^
+ Helto Bincenza
?    ^  ^      ^

4) Fourth test (four characters are differents -> Anomaly)

>>> a = "Hello Vincenzo\n".splitlines(1)
>>> b = "Halto Bincenza\n".splitlines(1)
>>> a
['Hello Vincenzo\n']
>>> b
['Halto Bincenza\n']
>>> diff = difflib.ndiff(a,b)
>>> print(''.join(diff))
- Hello Vincenzo
+ Halto Bincenza

In this last test I expected 4 "^" characters as in previous tests, like this:

- Hello Vincenzo
?  ^ ^  ^      ^
+ Halto Bincenza
?  ^ ^  ^      ^

but I have a response completly different. This is a Bug or I did not understand something :)

Thank you very much for your support.

----------
components: Library (Lib)
messages: 274023
nosy: vincenzo gisondi
priority: normal
severity: normal
status: open
title: Difflib.ndiff (Problem on identification of changes as Diff Style)
type: behavior
versions: Python 2.7

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


More information about the New-bugs-announce mailing list