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

bpo-30806 netrc.__repr__() is broken for writing to file #2491

Merged
merged 4 commits into from Sep 30, 2017

Conversation

Bezier89
Copy link
Contributor

@Bezier89 Bezier89 commented Jun 29, 2017

@the-knights-who-say-ni
Copy link

the-knights-who-say-ni commented Jun 29, 2017

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!

@Bezier89 Bezier89 changed the title Fix bug in netrc.__repr__() Issue 30806 netrc.__repr__() is broken for writing to file Jun 29, 2017
@Bezier89 Bezier89 changed the title Issue 30806 netrc.__repr__() is broken for writing to file bpo-NNNN netrc.__repr__() is broken for writing to file Jun 29, 2017
@Bezier89 Bezier89 changed the title bpo-NNNN netrc.__repr__() is broken for writing to file bpo-30806 netrc.__repr__() is broken for writing to file Jun 29, 2017
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"
Copy link
Member

@methane methane Aug 3, 2017

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"

Copy link
Contributor Author

@Bezier89 Bezier89 Aug 3, 2017

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"
Copy link
Member

@methane methane Aug 3, 2017

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"

Copy link
Contributor Author

@Bezier89 Bezier89 Aug 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Bezier89
Copy link
Contributor Author

Bezier89 commented Sep 15, 2017

@methane, I updated this to use f-strings. Is there anything else that needs to be done for this to be merged?

@methane
Copy link
Member

methane commented Sep 16, 2017

Sorry for delay.
Would you add NEWS file and test?

@methane
Copy link
Member

methane commented Sep 16, 2017

See https://devguide.python.org/committing/#what-s-new-and-news-entries for how to create NEWS entry file.

@Bezier89
Copy link
Contributor Author

Bezier89 commented Sep 29, 2017

@methane This is done. Let me know if it looks good!

@methane methane merged commit b24cd05 into python:master Sep 30, 2017
@methane
Copy link
Member

methane commented Sep 30, 2017

Thanks.

@sloria
Copy link

sloria commented Nov 2, 2017

Will this fix be backported to python 2.7? The issue exists there as well.

@miss-islington
Copy link
Contributor

miss-islington commented Nov 3, 2017

Thanks @Bezier89 for the PR, and @methane for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 3, 2017
netrc file format doesn't support quotes and escapes.

See https://linux.die.net/man/5/netrc
(cherry picked from commit b24cd05)
@bedevere-bot
Copy link

bedevere-bot commented Nov 3, 2017

GH-4244 is a backport of this pull request to the 3.6 branch.

@methane
Copy link
Member

methane commented Nov 3, 2017

@sloria Will and will not.
This pull request need modify to backport to 2.7, since it using f-string.
If you create pull request for 2.7, please mention me. I'll see it.

@sloria
Copy link

sloria commented Nov 3, 2017

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.

methane pushed a commit that referenced this pull request Nov 3, 2017
netrc file format doesn't support quotes and escapes.

See https://linux.die.net/man/5/netrc
(cherry picked from commit b24cd05)
sloria pushed a commit to sloria/cpython that referenced this pull request Nov 4, 2017
@sloria
Copy link

sloria commented Nov 4, 2017

@methane OK, I've made a PR for 2.7: #4276

methane pushed a commit that referenced this pull request Dec 10, 2017
netrc file format doesn't support quotes and escapes.

See https://linux.die.net/man/5/netrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants