GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-28806: Improve the netrc library by zhangyangyu · Pull Request #127 · python/cpython

Conversation

@zhangyangyu

@zhangyangyu zhangyangyu commented Feb 16, 2017

Copy link
Copy Markdown
Member

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yan12125, alindt, mszczepanczyk, and Sipty reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
@zhangyangyu
Improve netrc library largely
601b3f7
@zhangyangyu zhangyangyu added the type-feature A feature request or enhancement label Feb 16, 2017
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 16, 2017
@zhangyangyu
zhangyangyu force-pushed the workspace branch from 8384aca to 601b3f7 Compare February 16, 2017 05:31
@dmerejkowsky

dmerejkowsky commented Feb 18, 2017

Copy link
Copy Markdown

@zhangyangyu Nice work! I also wrote a tiny patch for netrc, so maybe you could integrate #123 in your PR as well?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zhangyangyu

zhangyangyu commented Feb 20, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@dmerejkowsky I wrote this patch months ago, so I have to spend some time picking it up to see if there is any possibility. Happy to see someone also interested in improving netrc.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dmerejkowsky

dmerejkowsky commented Feb 20, 2017

Copy link
Copy Markdown

OK, then. Hopefully our PRs won't conflict with each other, so this not a big deal.

Keep up the good work!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yan12125 yan12125 mentioned this pull request Jun 19, 2017
.netrc file: add support for passwords containing spaces ytdl-org/youtube-dl#13434
Open
4 of 8 tasks
akruis referenced this pull request in stackless-dev/stackless Sep 5, 2017
Anselm Kruis
merge 3.4-slp (Stackless #127, pickling fixes)
785c16c
akruis referenced this pull request in stackless-dev/stackless Sep 5, 2017
Anselm Kruis
merge 3.4-slp (Stackless #127, use C-Python pickling)
1a49b66
akruis pushed a commit to akruis/cpython that referenced this pull request Sep 9, 2017
Anselm Kruis
Issue python#107: fix the __reduce__/__setstate__ protocol for genera…
8a2d22a
…tor and traceback objects

__setstate__ must accept the state returned by __reduce__. This was not the case for generator
and trace-back objects. This commit fixes this. The next commit (merge of issue python#127) adds the relevant test cases.
Additionally amends changelog.txt.

https://bitbucket.org/stackless-dev/stackless/issues/107
akruis pushed a commit to akruis/cpython that referenced this pull request Sep 9, 2017
Anselm Kruis
merge 3.3-slp (Stackless python#127, pickling fixes)
9994a00
akruis pushed a commit to akruis/cpython that referenced this pull request Sep 9, 2017
Anselm Kruis
merge 3.3-slp (Stackless python#127, use C-Python pickling)
43b9010
akruis pushed a commit to akruis/cpython that referenced this pull request Sep 9, 2017
Anselm Kruis
Issue python#127: Fix pickling and copying of various types. Fix pick…
18a3e59
…ling tests.

This change is based on f5f98595c6cc63b from 2.7-slp, but it is heavily modified for Python 3.

- Pickle 'callable-iterator' objects correctly. Previously the unpickled object had the type '_stackless._wrap.callable-iterator'.

- Fix pickling of 'method-wrapper' objects. Previously pickling them caused a SystemError exception.

- Fix copy.copy() for 'callable-iterator', 'method', 'dict_keys', 'dict_values' and 'dict_items' objects. Previously the copied object had the type '_stackless._wrap....'.

- Fix Stackless pickling tests. The method StacklessTestCase.dumps() didn't pass the pickle protocol to the pickler.

- Remove dead code in prickelpit.c. The code was used in older Stackless versions.
akruis pushed a commit to akruis/cpython that referenced this pull request Sep 9, 2017
Anselm Kruis
Issue python#127: use C-Python pickling for 'iterator' and 'callable_…
91712fb
…iterator'

Disable the Stackless specific code for pickling 'iterator' and 'callable_iterator' objects. C-Python 3.3 already pickles them.
Add tests to ensure, that Stackless can still unpickle old pickles.

https://bitbucket.org/stackless-dev/stackless/issues/127
@ghost ghost mentioned this pull request Sep 24, 2017
Improve frame and traceback pickling stackless-dev/stackless#107
Closed
@Mariatta Mariatta added needs rebase and removed needs rebase labels Oct 9, 2017
akruis pushed a commit to akruis/cpython that referenced this pull request Oct 10, 2017
Anselm Kruis
Merge 3.5-slp (Stackless python#127, pickling fixes)
79de128
akruis pushed a commit to akruis/cpython that referenced this pull request Oct 10, 2017
Anselm Kruis
Merge 3.5-slp (Stackless python#127, use C-Python pickling)
eae6aae
@zhangyangyu zhangyangyu added the awaiting review label Jan 18, 2018
@jjjake jjjake mentioned this pull request Mar 14, 2018
Feature: Auth should use .netrc instead of a .cfg jjjake/internetarchive#154
Closed
raspy
raspy reviewed Apr 17, 2018
View reviewed changes
Comment thread Lib/netrc.py
account = lexer.get_token()
elif tt == 'password':
if os.name == 'posix' and default_netrc:
if os.name == 'posix' and default_netrc and login != "anonymous":

@raspy raspy Apr 17, 2018

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This assumes that login has already been parsed, but the netrc format does not require providing login token before password token. It would be better to perform this check on storing parsed data into self.hosts[entryname], when all machine-related data is parsed and available.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thedrow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
auvipy
auvipy reviewed Oct 9, 2018
View reviewed changes

@auvipy auvipy left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

also please re base

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/netrc.rst

.. versionchanged:: 3.4 Added the POSIX permission check.

.. versionchanged:: 3.7

@auvipy auvipy Oct 9, 2018

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

3.8

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@auvipy auvipy Sep 17, 2019

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

you can retarget it for python 3.9

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chrahunt chrahunt mentioned this pull request Oct 27, 2018
Support credentials in configuration for private PyPI pypa/pip#4315
Closed
serhiy-storchaka
serhiy-storchaka reviewed Oct 29, 2018
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm not sure, but it may be worth to backport these changes to maintained versions. It fixes several bugs in the .netrc file parsing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/netrc.rst

.. versionchanged:: 3.4 Added the POSIX permission check.

.. versionchanged:: 3.7

@serhiy-storchaka serhiy-storchaka Apr 19, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

3.8

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/netrc.py
continue
if ch == "\"":
for ch in fiter:
if ch != "\"":

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I would revert this condition.

if ch == '"':
    return token

And removed continue.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thedrow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/netrc.py
self.lineno = 1
self.instream = fp
self.whitespace = "\n\t\r "
self._stack = []

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It is not a stack, it is a queue. I suggest to rename it to pushback, as in shlex.lexer.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/netrc.py
for ch in fiter:
if ch in self.whitespace:
continue
if ch == "\"":

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

'"'?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thedrow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/netrc.py
ch = self._read_char()
token += ch
for ch in fiter:
if ch not in self.whitespace:

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The same as above.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thedrow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/netrc.py
entryname = 'default'
elif tt == 'macdef': # Just skip to end of macdefs
elif tt == 'macdef':
entryname = lexer.get_token()

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You need to read and ignore the rest of the line after the macro name.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/netrc.py
raise NetrcParseError(
"Macro definition missing null line terminator.",
file, lexer.lineno)
if line == '\n':

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Add a comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thedrow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/netrc.py
for host in self.hosts.keys():
attrs = self.hosts[host]
rep = rep + "machine "+ host + "\n\tlogin " + repr(attrs[0]) + "\n"
rep = rep + "machine "+ host + "\n\tlogin " + attrs[0] + "\n"

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Perhaps we need a special function which escapes whitespaces and other special characters?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/netrc.py
ch = self._read_char()
token += ch
for ch in fiter:
if ch not in self.whitespace:

@serhiy-storchaka serhiy-storchaka Oct 29, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suggest to add a flag for denoting whether the terminating whitespace was '\n'. It will be helpful for comments and macdef.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thedrow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@csabella

csabella commented May 20, 2019

Copy link
Copy Markdown
Contributor

@zhangyangyu, would you be able to address Serhiy's review from October? Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zhangyangyu

zhangyangyu commented May 20, 2019

Copy link
Copy Markdown
Member Author

@csabella I am busy in my job now and this issue has been a long time even myself needs to reacquaint with it. But October seems not that hard to me. Is 3.8 going to release on October?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@csabella

csabella commented May 31, 2019

Copy link
Copy Markdown
Contributor

@zhangyangyu, sorry, I meant that Serhiy had left a comment last October, not that this needs to be looked at before the next October. The cutoff for 3.8 is this coming Monday (2019-06-03). I hope you still find time to look at it in the next few months. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eamanu

eamanu commented Sep 18, 2019

Copy link
Copy Markdown
Contributor

Hello I can continue this PR if your consider good.

Cc @csabella

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jayvdb jayvdb mentioned this pull request Jan 7, 2020
Store token in a dotfile fridex/githubcap#9
Open
@eamanu

eamanu commented Jun 21, 2020

Copy link
Copy Markdown
Contributor

Hi @auvipy @csabella @zhangyangyu There is some plan with this PR?
Was open 3 years ago. If the author is still interested on this bugs
resolution we could open a new PR.

What's your opinion?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thedrow

thedrow commented Sep 2, 2020

Copy link
Copy Markdown
Contributor

@eamanu I think that at this point, you can proceed with fixing the problems uncovered during code review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HighnessAtharva

HighnessAtharva commented May 24, 2021

Copy link
Copy Markdown

So should this PR be closed?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eamanu eamanu mentioned this pull request May 24, 2021
bpo-28806: Continue work: improve the netrc library #26330
Merged
@thedrow

thedrow commented May 24, 2021

Copy link
Copy Markdown
Contributor

I think so.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nanjekyejoannah

nanjekyejoannah commented May 24, 2021

Copy link
Copy Markdown
Contributor

Closing this PR since another PR #26330 continues and addresses comments on this thread. All reviews should move to the new PR.

thedrow reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nanjekyejoannah nanjekyejoannah closed this May 24, 2021
@zhangyangyu zhangyangyu mentioned this pull request Oct 29, 2022
Improve the netrc library #72992
Closed
@gvanrossum gvanrossum mentioned this pull request Aug 22, 2023
heap-use-after-free in _PyFunction_LookupByVersion #108253
Closed
This was referenced Feb 11, 2025
segmentfault when pip installing setuptools #129992
Closed
segmentfault when pip installing setuptools #129993
Closed
SonicField added a commit to SonicField/cpython that referenced this pull request Apr 24, 2026
@SonicField
phoenix-asm: PhxMem has_base flag (DSecondary-2 W-C2 follow-up)
fb4cb05
Pays the structural debt logged by W-C2 push 45 (9e342ab). The
W-C2 fix overloaded is_abs_addr=1 to trigger SIB pure-disp32 encoding
in phx_fs_ptr because PhxMem zero-init couldn't distinguish 'no base
register' from 'base = RAX (id=0)'. That overload was a workaround,
not a fix to the underlying flaw — pythia python#127 flagged the
structural-fix-rejected pattern.

Fix: add explicit has_base flag to PhxMem (mirror of has_index).
Constructors that take a base register (phx_ptr, phx_ptr_index,
phx_a64_mem/_pre/_post) set has_base=1; pure-displacement constructors
(phx_fs_ptr) leave has_base=0 via zero-init. encode_modrm_mem branches
on !has_base between the is_abs_addr branch and the base-register
fallback, emitting the SIB pure-disp32 form (04 25 disp32). FS segment
prefix is independently emitted by emit_segment_prefix.

phx_fs_ptr no longer needs the is_abs_addr workaround; restored to
clean semantics (has_base=0 from zero-init is the structural marker).

Other PhxMem callsite audit (no other changes needed):
- frame_asm_c.c:198 label_mem: is_label_rel branch fires first
- autogen_translate_c.c:1649 x86_operand_to_mem: STACK/IND use phx_ptr/
  phx_ptr_index (has_base=1); MEM uses is_abs_addr (branch fires first)
- arch.c:45+55 jit_arch_ptr_offset/_resolve: returns from phx_ptr
  (has_base=1)

Note (librarian 17:27:04Z): the 1afc0fa 2026-04-06 commit was a
stale-reference cleanup of a never-existing field, not a deliberate
has_base rejection. DSecondary-2 is fresh ground; no prior decision is
being reversed.

Auth chain: theologian patch-shape APPROVE 17:50:43Z (structural
verification: encoder branch order is_abs_addr → is_label_rel →
!has_base → base-register fallback; ARM64 helpers correctly set
has_base=1; other-callsite audit consistent); testkeeper pre-commit
BUILD PASS + JIT smoke PASS 17:53:26Z; supervisor 17:18:11Z queue
re-sequence (pay structural debt while surface fresh).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
+2 more reviewers
@raspy raspy raspy left review comments
@auvipy auvipy auvipy left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

12 participants

@zhangyangyu @dmerejkowsky @csabella @eamanu @thedrow @HighnessAtharva @nanjekyejoannah @raspy @serhiy-storchaka @auvipy @Mariatta @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.