Coder Social home page Coder Social logo

Comments (3)

tomauty avatar tomauty commented on July 1, 2024

Looks like minimal differences like this are not reported by the underlying library being used, i.e. difflib._mdiff.

Per the mdiff spec:

def mdiff(self):
        r"""The difflib._mdiff() function returns an interator which returns a
        tuple: (from line tuple, to line tuple, boolean flag)

        from/to line tuple -- (line num, line text)
            line num -- integer or None (to indicate a context separation)
            line text -- original line text with following markers inserted:
                '\0+' -- marks start of added text
                '\0-' -- marks start of deleted text
                '\0^' -- marks start of changed text
                '\1' -- marks end of added/deleted/changed text

        boolean flag -- None indicates context separation, True indicates
            either "from" or "to" line contains a change, otherwise False.
        """
        return difflib._mdiff(self._get_old_text(), self._get_new_text())

And the output for your test files through mdiff is as follows:

(u'\x00-aaa\x01', u'\x00+aaa bbb ccc\x01')

So minimal differences would be a non-trivial change. Hope this helps shed some light on the issue. I also have a vested interest in this feature, but don't have enough python knowledge to make a change this substantial. May be good to look into a different difflib function?

from icdiff.

jeffkaufman avatar jeffkaufman commented on July 1, 2024

Yes, this looks like a bug in difflib. Are you up for filing a bug against python?

from icdiff.

lurch avatar lurch commented on July 1, 2024

Similar to my comment on #58, it seems that difflib is sometimes able to do the correct thing, depending on the input. No, I've got no idea why it works the way it does! ;-)

import difflib
>>> list(difflib.ndiff(['aaa'], ['aaa bbb ccc']))
['- aaa', '+ aaa bbb ccc']
>>> list(difflib.ndiff(['aaaa'], ['aaaa bbb ccc']))
['- aaaa', '+ aaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaa'], ['aaaaa bbb ccc']))
['- aaaaa', '+ aaaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaaa'], ['aaaaaa bbb ccc']))
['- aaaaaa', '+ aaaaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaaaa'], ['aaaaaaa bbb ccc']))
['- aaaaaaa', '+ aaaaaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaaaaa'], ['aaaaaaaa bbb ccc']))
['- aaaaaaaa', '+ aaaaaaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaaaaaa'], ['aaaaaaaaa bbb ccc']))
['- aaaaaaaaa', '+ aaaaaaaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaaaaaaa'], ['aaaaaaaaaa bbb ccc']))
['- aaaaaaaaaa', '+ aaaaaaaaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaaaaaaaa'], ['aaaaaaaaaaa bbb ccc']))
['- aaaaaaaaaaa', '+ aaaaaaaaaaa bbb ccc']
>>> list(difflib.ndiff(['aaaaaaaaaaaa'], ['aaaaaaaaaaaa bbb ccc']))
['- aaaaaaaaaaaa', '+ aaaaaaaaaaaa bbb ccc', '?             ++++++++\n']
>>> list(difflib.ndiff(['aaaaaaaaaaaa'], ['aaaaaaaaaaaa bbbb ccc']))
['- aaaaaaaaaaaa', '+ aaaaaaaaaaaa bbbb ccc']
>>> list(difflib.ndiff(['aaaaaaaaaaaaa'], ['aaaaaaaaaaaaa bbbb ccc']))
['- aaaaaaaaaaaaa', '+ aaaaaaaaaaaaa bbbb ccc']
>>> list(difflib.ndiff(['aaaaaaaaaaaaaa'], ['aaaaaaaaaaaaaa bbbb ccc']))
['- aaaaaaaaaaaaaa', '+ aaaaaaaaaaaaaa bbbb ccc', '?               +++++++++\n']

from icdiff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.