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
Changes from 1 commit
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: 4 additions & 1 deletion Lib/netrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

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

what about inline the if clause?

deafult_file_name = '.netrc' if os.name != 'nt' else '_netrc'

Copy link
Author

Choose a reason for hiding this comment

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

I’m good with that. I’m currently on vacation. Will be back in a week to update PR title and formatting.

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:
Expand Down