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
bpo-30806 netrc.__repr__() is broken for writing to file #2491
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
Lib/netrc.py
Outdated
@@ -127,10 +127,10 @@ def __repr__(self): | |||
rep = "" | |||
for host in self.hosts.keys(): | |||
attrs = self.hosts[host] | |||
rep = rep + "machine "+ host + "\n\tlogin " + repr(attrs[0]) + "\n" | |||
rep = rep + "machine "+ host + "\n\tlogin " + str(attrs[0]) + "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rep += f"machine {host}\n\tlogin {attrs[0]}\n"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Lib/netrc.py
Outdated
rep = rep + "account " + repr(attrs[1]) | ||
rep = rep + "\tpassword " + repr(attrs[2]) + "\n" | ||
rep = rep + "\taccount " + str(attrs[1]) + "\n" | ||
rep = rep + "\tpassword " + str(attrs[2]) + "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rep += f"\taccount {attrs[1]}\n"
rep += f"\tpassword {attrs[2]}\n"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@methane, I updated this to use f-strings. Is there anything else that needs to be done for this to be merged? |
Sorry for delay. |
See https://devguide.python.org/committing/#what-s-new-and-news-entries for how to create NEWS entry file. |
@methane This is done. Let me know if it looks good! |
Thanks. |
Will this fix be backported to python 2.7? The issue exists there as well. |
netrc file format doesn't support quotes and escapes. See https://linux.die.net/man/5/netrc (cherry picked from commit b24cd05)
GH-4244 is a backport of this pull request to the 3.6 branch. |
@sloria Will and will not. |
I needed this fix, so I released a library that addresses this issue (and also adds write functionality): https://github.com/sloria/tinynetrc . I can't make any promises, but if I get some time, I'll look into backporting to 2.7. |
netrc file format doesn't support quotes and escapes. See https://linux.die.net/man/5/netrc (cherry picked from commit b24cd05)
netrc file format doesn't support quotes and escapes. See https://linux.die.net/man/5/netrc
netrc file format doesn't support quotes and escapes. See https://linux.die.net/man/5/netrc
https://bugs.python.org/issue30806