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

netrc.__repr__() is broken for writing to file #74989

Closed
Bezier89 mannequin opened this issue Jun 29, 2017 · 4 comments
Closed

netrc.__repr__() is broken for writing to file #74989

Bezier89 mannequin opened this issue Jun 29, 2017 · 4 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@Bezier89
Copy link
Mannequin

Bezier89 mannequin commented Jun 29, 2017

BPO 30806
Nosy @methane, @Bezier89
PRs
  • bpo-30806 netrc.__repr__() is broken for writing to file #2491
  • [3.6] bpo-30806: Fix netrc.__repr__() format (GH-2491) #4244
  • [2.7] bpo-30806: Fix netrc.__repr__() format (GH-2491) #4276
  • 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 2017-11-03.05:37:32.768>
    created_at = <Date 2017-06-29.19:12:21.752>
    labels = ['3.7', 'type-bug', 'library']
    title = 'netrc.__repr__() is broken for writing to file'
    updated_at = <Date 2017-12-10.06:10:05.430>
    user = 'https://github.com/Bezier89'

    bugs.python.org fields:

    activity = <Date 2017-12-10.06:10:05.430>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-03.05:37:32.768>
    closer = 'methane'
    components = ['Library (Lib)']
    creation = <Date 2017-06-29.19:12:21.752>
    creator = 'Bezier89'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30806
    keywords = ['patch']
    message_count = 4.0
    messages = ['297296', '303398', '305461', '307943']
    nosy_count = 2.0
    nosy_names = ['methane', 'Bezier89']
    pr_nums = ['2491', '4244', '4276']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30806'
    versions = ['Python 3.6', 'Python 3.7']

    @Bezier89
    Copy link
    Mannequin Author

    Bezier89 mannequin commented Jun 29, 2017

    Have any valid .netrc file. For testing purposes you can use this:

    machine abc.xyz login myusername password mypassword

    The documentation for netrc.__repr__() states that it "dumps the class data as a string in the format of a netrc file". However, when you try to actually do this, you'll encounter a nasty bug. This can be seen by running the follow commands:

    auth = netrc.netrc(os.path.expanduser(r"~\.netrc"))
    print(auth.__repr__())

    The expected output is:

    machine abc.xyz
    login myusername
    password mypassword

    The actual output is:

    machine abc.xyz
    login 'myusername'
    password 'mypassword'

    If you write this back out to the .netrc file, authentication will fail since incorrect username/password (with ' character at beginning at end) will be passed.

    @Bezier89 Bezier89 mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 29, 2017
    @methane
    Copy link
    Member

    methane commented Sep 30, 2017

    New changeset b24cd05 by INADA Naoki (James Sexton) in branch 'master':
    bpo-30806 netrc.__repr__() is broken for writing to file (GH-2491)
    b24cd05

    @methane
    Copy link
    Member

    methane commented Nov 3, 2017

    New changeset 5fbe5e1 by INADA Naoki (Miss Islington (bot)) in branch '3.6':
    bpo-30806: Fix netrc.__repr__() format (GH-2491)
    5fbe5e1

    @methane methane added the 3.7 (EOL) end of life label Nov 3, 2017
    @methane methane closed this as completed Nov 3, 2017
    @methane
    Copy link
    Member

    methane commented Dec 10, 2017

    New changeset 3b9173d by INADA Naoki (Steven Loria) in branch '2.7':
    bpo-30806: Fix netrc.__repr__() format (GH-2491)
    3b9173d

    @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.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant