mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-30806 netrc.__repr__() is broken for writing to file (GH-2491)
netrc file format doesn't support quotes and escapes. See https://linux.die.net/man/5/netrc
This commit is contained in:
parent
3d2b407da0
commit
b24cd055ec
3 changed files with 13 additions and 9 deletions
12
Lib/netrc.py
12
Lib/netrc.py
|
|
@ -127,15 +127,15 @@ class netrc:
|
|||
rep = ""
|
||||
for host in self.hosts.keys():
|
||||
attrs = self.hosts[host]
|
||||
rep = rep + "machine "+ host + "\n\tlogin " + repr(attrs[0]) + "\n"
|
||||
rep += f"machine {host}\n\tlogin {attrs[0]}\n"
|
||||
if attrs[1]:
|
||||
rep = rep + "account " + repr(attrs[1])
|
||||
rep = rep + "\tpassword " + repr(attrs[2]) + "\n"
|
||||
rep += f"\taccount {attrs[1]}\n"
|
||||
rep += f"\tpassword {attrs[2]}\n"
|
||||
for macro in self.macros.keys():
|
||||
rep = rep + "macdef " + macro + "\n"
|
||||
rep += f"macdef {macro}\n"
|
||||
for line in self.macros[macro]:
|
||||
rep = rep + line
|
||||
rep = rep + "\n"
|
||||
rep += line
|
||||
rep += "\n"
|
||||
return rep
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue