python / python/cpython

netrc: accept open file object as initialization argument

Open
#98,235 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Feature or enhancement

Make netrc class accept open file object (io.TextIOBase subclass) as an initialization argument.

Pitch

Providing netrc data via StringIO makes it possible to retrieve it from a verity of different sources e.g. an encrypted file. With few additional lines lines of code .netrc becomes a secure password store.

import gpg

with open(file) as file_gpg:
    with gpg.Context() as c:
        plaintext = c.decrypt(file_gpg)[0]
        nrc_data = io.StringIO(plaintext.decode('utf-8'))
        nrc = netrc.netrc(nrc_data)
passwd = nrc.authenticators(hostname)[2]

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.

Research direction

Start at the netrc.netrc initialization entry point and compare its current argument handling with the provided io.StringIO example. Confirm how an open io.TextIOBase object should be consumed without changing existing inputs, then verify that parsing and authenticator lookup still produce the expected results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.