Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-135788: Support NETRC environment variable innetrc#135802

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
berthin wants to merge19 commits intopython:main
base:main
Choose a base branch
Loading
fromberthin:add_netrc_envvar

Conversation

berthin
Copy link

@berthinberthin commentedJun 21, 2025
edited by github-actionsbot
Loading

  • This change adds support for reading the NETRC environment variable when no file is passed as argument to the constructor of netrc, which takes precedence over the user's home directory .netrc file.
  • Test cases are updated to check all initialisation scenarios.
  • The documentation for netrc has been updated to reflect this behavior.

📚 Documentation preview 📚:https://cpython-previews--135802.org.readthedocs.build/

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

Copy link
Member

@picnixzpicnixz left a comment

Choose a reason for hiding this comment

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

Avoid verbose comments in tests in general unless they are needed. Most of the time, the code is small enough to understand what happens without the needs of a docstring.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@python-cla-bot
Copy link

python-cla-botbot commentedJun 22, 2025
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

envvar_netrc = os.environ.get("NETRC", "")
home_netrc = os.path.join(os.path.expanduser("~"), ".netrc")
file = file or envvar_netrc or home_netrc
default_netrc = (file == home_netrc)
Copy link
Member

Choose a reason for hiding this comment

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

The paths may be different but resolve to the same file.

Copy link
Author

Choose a reason for hiding this comment

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

Could you please elaborate more? what's the expected behavior in that case?

@picnixzpicnixz changed the titlegh-135788: Support NETRC environment variable in netrc and update documentationgh-135788: Support NETRC environment variable innetrcJun 22, 2025
@picnixz
Copy link
Member

So there is some WASI issue because of some missing OS function. I think it's because we previously never tested some code path that used that function, hence the issue. For now just ignore this failure.

Copy link
Member

@picnixzpicnixz left a comment
edited
Loading

Choose a reason for hiding this comment

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

So the WASI issue is innetrc.py itself and thedefault_netrc stuff.

I suspect that theif os.name == 'posix' check is not sufficient and we needif hasattr(os, "getuid"). We should have a separate PR and an other issue just for that, so for now you can skip the failing test on WASI (namelyonly the "use_default_netrc_in_home", not the others) and you should also document that this is not supported on WASI (when the PR fixing the WASI handling lands, we'll update that note, but until then the docs should be consistent and say that NETRC envvar is not supported on WASI)

@picnixz
Copy link
Member

picnixz commentedJun 22, 2025
edited
Loading

I'll work on the WASI failure here#135815. If my PR lands before yours, then you won't need to change the test. I suggest not to change anything for now as I think I can fix it by the end of the day.

@picnixz
Copy link
Member

The WASI test should be fixed. You can now resolve the conflicts (sorry for them!)

berthin reacted with hooray emoji

@berthin
Copy link
Author

The WASI test should be fixed. You can now resolve the conflicts (sorry for them!)

No worries, and thanks for fixing that issue!

@berthin
Copy link
Author

I don't get why I get theResult: ENV CHANGED then ENV CHANGED inUbuntu (free-threading) / build and test (ubuntu-24.04), will take a look later during the week.

picnixz reacted with thumbs up emoji

@picnixz
Copy link
Member

I've restarted the CI job. It might be a false positive as it's under free-threading and we've had similar failures

@cmaloney
Copy link
Contributor

Commented on the issue, adding for visibility here: Multiple http libraries which use CPython'snetrc implement a security featuretrust_env which indicates whether environment variables (and sometimes files in home directories) should be trusted, default reading environment variables in an underlying library seems likely to bypass that, so I think this needs to be opt-in for things that usenetrc.

picnixz reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@picnixzpicnixzpicnixz left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@berthin@picnixz@cmaloney

[8]ページ先頭

©2009-2025 Movatter.jp