Skip to content

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

Closed

Description

@Bezier89
mannequin
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']

    Activity

    1. Bezier89 commented on Jun 29, 2017

      Bezier89mannequin
      MannequinAuthor

      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.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Jun 29, 2017
    3. methane commented on Sep 30, 2017

      @methane
      Member

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

    4. methane commented on Nov 3, 2017

      @methane
      Member

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

    5. methane commented on Dec 10, 2017

      @methane
      Member

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

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions