Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PermissionError when loading .netrc (#7237) (#7378) #7394

Conversation

jgosmann
Copy link
Contributor

@jgosmann jgosmann commented Jul 20, 2023

What do these changes do?

If no NETRC environment variable is provided and the .netrc path cannot be accessed due to missing permission, a PermissionError was raised instead of returning None. See issue #7237. This PR fixes the issue.

If the changes look good, I can also prepare backports.

Are there changes in behavior for the user?

If the .netrc cannot be accessed due to a permission problem (and the NETRC environment variable is unset), no PermissionError will be raised. Instead it will be silently ignored.

Related issue number

Fixes #7237

Backport of #7378

(cherry picked from commit 0d2e43b)

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

## What do these changes do?

If no NETRC environment variable is provided and the .netrc path cannot
be accessed due to missing permission, a PermissionError was raised
instead of returning None. See issue aio-libs#7237. This PR fixes the issue.

If the changes look good, I can also prepare backports.

## Are there changes in behavior for the user?

If the .netrc cannot be accessed due to a permission problem (and the
`NETRC` environment variable is unset), no `PermissionError` will be
raised. Instead it will be silently ignored.

## Related issue number

Fixes aio-libs#7237

(cherry picked from commit 0d2e43b)

# Conflicts:
#	aiohttp/helpers.py
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jul 20, 2023
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #7394 (4cd7608) into 3.9 (3f66737) will increase coverage by 0.00%.
The diff coverage is 94.44%.

@@           Coverage Diff           @@
##              3.9    #7394   +/-   ##
=======================================
  Coverage   97.27%   97.28%           
=======================================
  Files         107      107           
  Lines       31605    31622   +17     
  Branches     4013     4016    +3     
=======================================
+ Hits        30745    30762   +17     
  Misses        653      653           
  Partials      207      207           
Flag Coverage Δ
CI-GHA 97.22% <94.44%> (+<0.01%) ⬆️
OS-Linux 96.91% <94.44%> (+<0.01%) ⬆️
OS-Windows 94.53% <94.44%> (+<0.01%) ⬆️
OS-macOS 96.59% <94.44%> (+<0.01%) ⬆️
Py-3.10.11 94.44% <94.44%> (+<0.01%) ⬆️
Py-3.10.12 96.78% <94.44%> (+<0.01%) ⬆️
Py-3.11.0 96.50% <94.44%> (+<0.01%) ⬆️
Py-3.8.10 94.42% <94.44%> (+<0.01%) ⬆️
Py-3.8.17 96.72% <94.44%> (+<0.01%) ⬆️
Py-3.9.13 94.42% <94.44%> (+<0.01%) ⬆️
Py-3.9.17 96.76% <94.44%> (+<0.01%) ⬆️
Py-pypy7.3.11 94.12% <88.88%> (-0.01%) ⬇️
VM-macos 96.59% <94.44%> (+<0.01%) ⬆️
VM-ubuntu 96.91% <94.44%> (+<0.01%) ⬆️
VM-windows 94.53% <94.44%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiohttp/helpers.py 95.10% <80.00%> (+0.03%) ⬆️
tests/test_helpers.py 98.83% <100.00%> (+0.03%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jgosmann
Copy link
Contributor Author

I think the failure of "CI / Test (macos, 3.11.0-alpha - 3.11.0, true, Y) (pull_request)" is unrelated to the changes. The log says: pytest: command not found

@Dreamsorcerer Dreamsorcerer merged commit a00fffd into aio-libs:3.9 Jul 22, 2023
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants