Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
83315ef
Bump version (#11685)
Dreamsorcerer Oct 17, 2025
381334b
[PR #11686/42fc48a6 backport][3.14] Raise benchmark timeout to 12 min…
patchback[bot] Oct 18, 2025
e6042d2
[PR #11686/42fc48a6 backport][3.13] Raise benchmark timeout to 12 min…
patchback[bot] Oct 18, 2025
f401e99
Bump iniconfig from 2.1.0 to 2.3.0 (#11692)
dependabot[bot] Oct 20, 2025
9529279
Bump pydantic from 2.12.2 to 2.12.3 (#11693)
dependabot[bot] Oct 20, 2025
0354bf1
Bump cython from 3.1.4 to 3.1.5 (#11694)
dependabot[bot] Oct 20, 2025
d7c3e1f
Bump sigstore/gh-action-sigstore-python from 3.0.1 to 3.1.0 (#11699)
dependabot[bot] Oct 21, 2025
231a172
Bump regex from 2025.9.18 to 2025.10.23 (#11702)
dependabot[bot] Oct 22, 2025
442d38f
Bump cython from 3.1.5 to 3.1.6 (#11710)
dependabot[bot] Oct 24, 2025
1d6513a
Bump pytest-codspeed from 4.1.1 to 4.2.0 (#11711)
dependabot[bot] Oct 24, 2025
322d177
Bump python-on-whales from 0.78.0 to 0.79.0 (#11712)
dependabot[bot] Oct 24, 2025
b4d9b89
Bump actions/download-artifact from 5 to 6 (#11721)
dependabot[bot] Oct 27, 2025
6d22d3a
Bump pip from 25.2 to 25.3 (#11722)
dependabot[bot] Oct 27, 2025
57ad7fa
[PR #11714/0d77d0d6 backport][3.14] Fix loading netrc when NETRC env …
patchback[bot] Oct 28, 2025
b734e04
[PR #11714/0d77d0d6 backport][3.13] Fix loading netrc when NETRC env …
patchback[bot] Oct 28, 2025
990c6b4
[PR #11724/82ce525b backport][3.14] Ensure cookies are still parsed a…
bdraco Oct 28, 2025
95daf0c
[PR #11724/82ce525b backport][3.13] Ensure cookies are still parsed a…
bdraco Oct 28, 2025
baf646f
[PR #11726/6cffcfd backport][3.14] Fix WebSocket compressed sends to …
bdraco Oct 28, 2025
5c75e63
[PR #11726/6cffcfd backport][3.13] Fix WebSocket compressed sends to …
bdraco Oct 28, 2025
91547df
Release 3.13.2 (#11733)
bdraco Oct 28, 2025
e1aec0a
Move dependency metadata from `setup.cfg` to `pyproject.toml`
cdce8p Oct 28, 2025
9b8f4b9
Merge branch '3.13' into 3.14
bdraco Oct 28, 2025
861c621
Merge branch '3.14'
bdraco Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[PR aio-libs#11714/0d77d0d6 backport][3.13] Fix loading netrc when NE…
…TRC env var is not set (aio-libs#11727)

Co-authored-by: J. Nick Koston <[email protected]>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
fixes aio-libs#11713
  • Loading branch information
4 people authored Oct 28, 2025
commit b734e0434731e11360fec74031f3deed02ee4717
1 change: 1 addition & 0 deletions CHANGES/11713.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed loading netrc credentials from the default :file:`~/.netrc` (:file:`~/_netrc` on Windows) location when the :envvar:`NETRC` environment variable is not set -- by :user:`bdraco`.
1 change: 1 addition & 0 deletions CHANGES/11714.bugfix.rst
9 changes: 1 addition & 8 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,14 +661,7 @@ async def _request(
auth = self._default_auth

# Try netrc if auth is still None and trust_env is enabled.
# Only check if NETRC environment variable is set to avoid
# creating an expensive executor job unnecessarily.
if (
auth is None
and self._trust_env
and url.host is not None
and os.environ.get("NETRC")
):
if auth is None and self._trust_env and url.host is not None:
auth = await self._loop.run_in_executor(
None, self._get_netrc_auth, url.host
)
Expand Down
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import base64
import os
import platform
import socket
import ssl
import sys
Expand Down Expand Up @@ -308,6 +309,23 @@ def netrc_other_host(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path:
return netrc_file


@pytest.fixture
def netrc_home_directory(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path:
"""Create a netrc file in a mocked home directory without setting NETRC env var."""
home_dir = tmp_path / "home"
home_dir.mkdir()
netrc_filename = "_netrc" if platform.system() == "Windows" else ".netrc"
netrc_file = home_dir / netrc_filename
netrc_file.write_text("default login netrc_user password netrc_pass\n")

home_env_var = "USERPROFILE" if platform.system() == "Windows" else "HOME"
monkeypatch.setenv(home_env_var, str(home_dir))
# Ensure NETRC env var is not set
monkeypatch.delenv("NETRC", raising=False)

return netrc_file


@pytest.fixture
def start_connection() -> Iterator[mock.Mock]:
with mock.patch(
Expand Down
18 changes: 16 additions & 2 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3785,12 +3785,12 @@ async def test_netrc_auth_from_env( # type: ignore[misc]


@pytest.mark.usefixtures("no_netrc")
async def test_netrc_auth_skipped_without_env_var( # type: ignore[misc]
async def test_netrc_auth_skipped_without_netrc_file( # type: ignore[misc]
headers_echo_client: Callable[
..., Awaitable[TestClient[web.Request, web.Application]]
],
) -> None:
"""Test that netrc authentication is skipped when NETRC env var is not set."""
"""Test that netrc authentication is skipped when no netrc file exists."""
client = await headers_echo_client(trust_env=True)
async with client.get("/") as r:
assert r.status == 200
Expand All @@ -3799,6 +3799,20 @@ async def test_netrc_auth_skipped_without_env_var( # type: ignore[misc]
assert "Authorization" not in content["headers"]


@pytest.mark.usefixtures("netrc_home_directory")
async def test_netrc_auth_from_home_directory( # type: ignore[misc]
headers_echo_client: Callable[
..., Awaitable[TestClient[web.Request, web.Application]]
],
) -> None:
"""Test that netrc authentication works from default ~/.netrc without NETRC env var."""
client = await headers_echo_client(trust_env=True)
async with client.get("/") as r:
assert r.status == 200
content = await r.json()
assert content["headers"]["Authorization"] == "Basic bmV0cmNfdXNlcjpuZXRyY19wYXNz"


@pytest.mark.usefixtures("netrc_default_contents")
async def test_netrc_auth_overridden_by_explicit_auth( # type: ignore[misc]
headers_echo_client: Callable[
Expand Down
15 changes: 13 additions & 2 deletions tests/test_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,8 @@ async def test_netrc_auth_skipped_without_trust_env(auth_server: TestServer) ->


@pytest.mark.usefixtures("no_netrc")
async def test_netrc_auth_skipped_without_netrc_env(auth_server: TestServer) -> None:
"""Test that netrc authentication is skipped when NETRC env var is not set."""
async def test_netrc_auth_skipped_without_netrc_file(auth_server: TestServer) -> None:
"""Test that netrc authentication is skipped when no netrc file exists."""
async with (
ClientSession(trust_env=True) as session,
session.get(auth_server.make_url("/")) as resp,
Expand All @@ -1375,6 +1375,17 @@ async def test_netrc_auth_skipped_without_netrc_env(auth_server: TestServer) ->
assert text == "no_auth"


@pytest.mark.usefixtures("netrc_home_directory")
async def test_netrc_auth_from_home_directory(auth_server: TestServer) -> None:
"""Test that netrc authentication works from default ~/.netrc location without NETRC env var."""
async with (
ClientSession(trust_env=True) as session,
session.get(auth_server.make_url("/")) as resp,
):
text = await resp.text()
assert text == "auth:Basic bmV0cmNfdXNlcjpuZXRyY19wYXNz"


@pytest.mark.usefixtures("netrc_default_contents")
async def test_netrc_auth_overridden_by_explicit_auth(auth_server: TestServer) -> None:
"""Test that explicit auth parameter overrides netrc authentication."""
Expand Down