[New-bugs-announce] [issue30806] netrc.__repr__() is broken for writing to file

James report at bugs.python.org
Thu Jun 29 15:12:21 EDT 2017


New submission from James:

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.

----------
components: Library (Lib)
messages: 297296
nosy: Bezier89
priority: normal
pull_requests: 2550
severity: normal
status: open
title: netrc.__repr__() is broken for writing to file
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30806>
_______________________________________


More information about the New-bugs-announce mailing list