From 37df335c6c1fc68a482bb222e3d793dc210459f9 Mon Sep 17 00:00:00 2001 From: Jerry Heiselman Date: Thu, 29 Apr 2021 15:08:12 -0500 Subject: [PATCH 1/4] Set default netrc file name correctly on Windows Fixes #43980 in the Python issue tracker --- Lib/netrc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/netrc.py b/Lib/netrc.py index f0ae48cfed9e67..234fea20d56a57 100644 --- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -23,7 +23,10 @@ class netrc: def __init__(self, file=None): default_netrc = file is None if file is None: - file = os.path.join(os.path.expanduser("~"), ".netrc") + default_file_name = ".netrc" + if os.name == "nt": + default_file_name = "_netrc" + file = os.path.join(os.path.expanduser("~"), default_file_name) self.hosts = {} self.macros = {} with open(file) as fp: From fc3726076c7115c0288831de84d4e407488fc615 Mon Sep 17 00:00:00 2001 From: Jerry Heiselman Date: Mon, 28 Jun 2021 10:50:55 -0500 Subject: [PATCH 2/4] issue43980: Set default netrc file name correctly on Windows This update to the commit address the conversation started by @eamanu --- Lib/netrc.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/netrc.py b/Lib/netrc.py index 234fea20d56a57..6e6b533a75c026 100644 --- a/Lib/netrc.py +++ b/Lib/netrc.py @@ -23,9 +23,7 @@ class netrc: def __init__(self, file=None): default_netrc = file is None if file is None: - default_file_name = ".netrc" - if os.name == "nt": - default_file_name = "_netrc" + default_file_name = ".netrc" if os.name != 'nt' else '_netrc' file = os.path.join(os.path.expanduser("~"), default_file_name) self.hosts = {} self.macros = {} From 7fefa7d9ae0311eb499b7a6ecbd40f41b89c1e7e Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 9 Jan 2023 21:29:59 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-01-09-21-29-58.gh-issue-43980.ij5v8a.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-01-09-21-29-58.gh-issue-43980.ij5v8a.rst diff --git a/Misc/NEWS.d/next/Library/2023-01-09-21-29-58.gh-issue-43980.ij5v8a.rst b/Misc/NEWS.d/next/Library/2023-01-09-21-29-58.gh-issue-43980.ij5v8a.rst new file mode 100644 index 00000000000000..f41f773380293c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-01-09-21-29-58.gh-issue-43980.ij5v8a.rst @@ -0,0 +1 @@ +Update the netrc library to use the de-facto default file name on Windows of _netrc From 44996e539e0ae16677a8b344ff9143805710036c Mon Sep 17 00:00:00 2001 From: Jerry Heiselman Date: Mon, 9 Jan 2023 15:34:21 -0600 Subject: [PATCH 4/4] Add what's new for netrc change --- Doc/whatsnew/3.12.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst index e9e25b9dc4664f..a85fd38bd731ea 100644 --- a/Doc/whatsnew/3.12.rst +++ b/Doc/whatsnew/3.12.rst @@ -253,6 +253,11 @@ dis :data:`~dis.hasarg` collection instead. (Contributed by Irit Katriel in :gh:`94216`.) +netrc +----- + +* Change the default file name for netrc to _netrc on Windows + os --