python / python/cpython

Use NETRC environment variable

Open
#135,788 15 comments 0 reactions 2 assignees View on GitHub

@picnixz is already working on this.

Since Aug 16, 2025.

stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

Hi,

I'd like to add support to the NETRC environment variable as documented in GNU inetuils v2.6 (https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html). Other tools and libraries are already supporting that envvar and I think it would be nice to aligned as well in that regard.

Supporting the envvar should be as simple as changing:

https://github.com/python/cpython/blob/7c4361564c3881946a5eca677607b4ffec0a566d/Lib/netrc.py#L70

with

file = os.environ.get("NETRC", None) or os.path.join(os.path.expanduser("~"), ".netrc")

Best regards,
Berthin

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-135802

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.