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

gh-88146: Set default netrc file name correctly on Windows #25732

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--

Expand Down
3 changes: 2 additions & 1 deletion Lib/netrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ 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' else '_netrc'
file = os.path.join(os.path.expanduser("~"), default_file_name)
self.hosts = {}
self.macros = {}
try:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update the netrc library to use the de-facto default file name on Windows of _netrc