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

ndiff reports incorrect location when diff strings contain tabs #81991

Closed
asottile mannequin opened this issue Aug 10, 2019 · 3 comments
Closed

ndiff reports incorrect location when diff strings contain tabs #81991

asottile mannequin opened this issue Aug 10, 2019 · 3 comments
Assignees
Labels
3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@asottile
Copy link
Mannequin

asottile mannequin commented Aug 10, 2019

BPO 37810
Nosy @tim-one, @rhettinger, @asottile
PRs
  • bpo-37810: Fix difflib ? hint in diff output when dealing with tabs #15201
  • [3.8] bpo-37810: Fix difflib ? hint in diff output when dealing with tabs (GH-15201) #15365
  • 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 = 'https://github.com/tim-one'
    closed_at = <Date 2019-08-21.20:26:10.221>
    created_at = <Date 2019-08-10.18:59:04.158>
    labels = ['3.8', 'library', '3.9']
    title = 'ndiff reports incorrect location when diff strings contain tabs'
    updated_at = <Date 2019-08-21.20:26:10.220>
    user = 'https://github.com/asottile'

    bugs.python.org fields:

    activity = <Date 2019-08-21.20:26:10.220>
    actor = 'tim.peters'
    assignee = 'tim.peters'
    closed = True
    closed_date = <Date 2019-08-21.20:26:10.221>
    closer = 'tim.peters'
    components = ['Library (Lib)']
    creation = <Date 2019-08-10.18:59:04.158>
    creator = 'Anthony Sottile'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37810
    keywords = ['patch']
    message_count = 3.0
    messages = ['349353', '349354', '349391']
    nosy_count = 3.0
    nosy_names = ['tim.peters', 'rhettinger', 'Anthony Sottile']
    pr_nums = ['15201', '15365']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37810'
    versions = ['Python 3.8', 'Python 3.9']

    @asottile
    Copy link
    Mannequin Author

    asottile mannequin commented Aug 10, 2019

    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

    @asottile asottile mannequin added 3.7 (EOL) end of life 3.8 (EOL) end of life 3.9 only security fixes labels Aug 10, 2019
    @rhettinger
    Copy link
    Contributor

    This seems like a reasonable suggestion to me. Am not sure whether it should be backported.

    Tim, what do you think?

    @rhettinger rhettinger added the stdlib Python modules in the Lib dir label Aug 10, 2019
    @asottile
    Copy link
    Mannequin Author

    asottile mannequin commented Aug 11, 2019

    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)

    @asottile asottile mannequin removed the 3.7 (EOL) end of life label Aug 11, 2019
    @tim-one tim-one closed this as completed Aug 21, 2019
    @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
    3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants