Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difflib.ndiff (Problem on identification of changes as Diff Style) #72100

Closed
vincenzogisondi mannequin opened this issue Aug 31, 2016 · 3 comments
Closed

Difflib.ndiff (Problem on identification of changes as Diff Style) #72100

vincenzogisondi mannequin opened this issue Aug 31, 2016 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@vincenzogisondi
Copy link
Mannequin

vincenzogisondi mannequin commented Aug 31, 2016

BPO 27913

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-08-31.14:43:22.322>
created_at = <Date 2016-08-31.14:37:05.391>
labels = ['invalid', 'type-bug', 'library']
title = 'Difflib.ndiff (Problem on identification of changes as Diff Style)'
updated_at = <Date 2016-08-31.15:04:57.491>
user = 'https://bugs.python.org/vincenzogisondi'

bugs.python.org fields:

activity = <Date 2016-08-31.15:04:57.491>
actor = 'vincenzo gisondi'
assignee = 'none'
closed = True
closed_date = <Date 2016-08-31.14:43:22.322>
closer = 'SilentGhost'
components = ['Library (Lib)']
creation = <Date 2016-08-31.14:37:05.391>
creator = 'vincenzo gisondi'
dependencies = []
files = []
hgrepos = []
issue_num = 27913
keywords = []
message_count = 3.0
messages = ['274023', '274025', '274027']
nosy_count = 2.0
nosy_names = ['SilentGhost', 'vincenzo gisondi']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue27913'
versions = ['Python 2.7']

@vincenzogisondi
Copy link
Mannequin Author

vincenzogisondi mannequin commented Aug 31, 2016

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
?              ^
  1. 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
?             ^^
  1. 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
?    ^  ^      ^
  1. 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.

@vincenzogisondi vincenzogisondi mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Aug 31, 2016
@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Aug 31, 2016

Since there are more than a quarter of all characters changed between two sequences, they are considered sufficiently different and no by-character comparison is shown.

@SilentGhost SilentGhost mannequin closed this as completed Aug 31, 2016
@SilentGhost SilentGhost mannequin added the invalid label Aug 31, 2016
@vincenzogisondi
Copy link
Mannequin Author

vincenzogisondi mannequin commented Aug 31, 2016

Ok now it is all clear.
Thank you very much, for your rapid and clear answer.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants