This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: netrc module looks for .netrc even on Windows where the convention is _netrc
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.11, Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jheiselman, steven.daprano
Priority: normal Keywords: patch

Created on 2021-04-29 20:02 by jheiselman, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 25732 jheiselman, 2021-04-29 20:10
Messages (4)
msg392348 - (view) Author: Jerry Heiselman (jheiselman) * Date: 2021-04-29 20:02
The netrc library defaults to looking for the .netrc file in the user's home directory. On Windows, this file is conventionally named _netrc. While one could pass the correct path to the library, the conventionally correct path should be used on all supported platforms.
msg392349 - (view) Author: Jerry Heiselman (jheiselman) * Date: 2021-04-29 20:10
Created a simple PR to correct this.
msg392355 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-04-29 21:32
This is a behaviour change not a simple bug fix. 3.6 through 3.9 are all in feature-freeze, and we're days away from the same for 3.10.

Not that I don't believe you about the _netrc convention on Windows, but do you have a link to a reliable source documenting that?
msg392356 - (view) Author: Jerry Heiselman (jheiselman) * Date: 2021-04-29 21:42
The netrc file has no formal standard, but the following supports the claim of its conventional naming.

Excerpt from https://curl.se/docs/manpage.html#-n:
"Makes curl scan the .netrc (_netrc on Windows) file in the user's home directory for login name and password."

Excerpt from https://www.labkey.org/Documentation/wiki-page.view?name=netrc:
"On a Mac, UNIX, or Linux system the netrc file should be named .netrc (dot netrc) and on Windows it should be named _netrc (underscore netrc)."

And a 9+ year old stack overflow post indicating that the use of _netrc on Windows is quite well established and has been for some time. I know it's not authoritative, but it does establish the length of history for this.
https://stackoverflow.com/questions/6031214/git-how-to-use-netrc-file-on-windows-to-save-user-and-password
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 88146
2021-04-29 21:42:22jheiselmansetmessages: + msg392356
2021-04-29 21:32:11steven.dapranosetversions: - Python 3.6, Python 3.7, Python 3.8, Python 3.9
nosy: + steven.daprano

messages: + msg392355

type: behavior -> enhancement
2021-04-29 20:10:42jheiselmansetkeywords: + patch

stage: patch review
messages: + msg392349
pull_requests: + pull_request24423
2021-04-29 20:02:55jheiselmancreate