-
-
Couldn't load subscription status.
- Fork 2.1k
Open
Labels
Description
Describe the bug
aiohttp v3.13.1 introduced a breaking change: the default .netrc file in the home directory is no longer used.
The snippet below returns a 401 with the latest version of aiohttp, while it works fine with previous versions.
To Reproduce
Here is my $HOME/.netrc
machine httpbin.org
login myuser
password mypassword
MRE:
import aiohttp
import asyncio
async def main():
url = "https://httpbin.org/basic-auth/myuser/mypassword"
async with aiohttp.ClientSession(trust_env=True) as session:
async with session.get(url) as response:
response.raise_for_status()
asyncio.run(main())Expected behavior
aiohttp used to read credentials by default from the .netrc file in the home directory.
Logs/tracebacks
---------------------------------------------------------------------------
ClientResponseError Traceback (most recent call last)
Cell In[2], line 13
9 async with session.get(url) as response:
10 response.raise_for_status()
---> 13 asyncio.run(main())
File ~/miniforge3/envs/test/lib/python3.13/asyncio/runners.py:195, in run(main, debug, loop_factory)
191 raise RuntimeError(
192 "asyncio.run() cannot be called from a running event loop")
194 with Runner(debug=debug, loop_factory=loop_factory) as runner:
--> 195 return runner.run(main)
File ~/miniforge3/envs/test/lib/python3.13/asyncio/runners.py:118, in Runner.run(self, coro, context)
116 self._interrupt_count = 0
117 try:
--> 118 return self._loop.run_until_complete(task)
119 except exceptions.CancelledError:
120 if self._interrupt_count > 0:
File ~/miniforge3/envs/test/lib/python3.13/asyncio/base_events.py:725, in BaseEventLoop.run_until_complete(self, future)
722 if not future.done():
723 raise RuntimeError('Event loop stopped before Future completed.')
--> 725 return future.result()
Cell In[2], line 10, in main()
8 async with aiohttp.ClientSession(trust_env=True) as session:
9 async with session.get(url) as response:
---> 10 response.raise_for_status()
File ~/miniforge3/envs/test/lib/python3.13/site-packages/aiohttp/client_reqrep.py:636, in ClientResponse.raise_for_status(self)
633 if not self._in_context:
634 self.release()
--> 636 raise ClientResponseError(
637 self.request_info,
638 self.history,
639 status=self.status,
640 message=self.reason,
641 headers=self.headers,
642 )
ClientResponseError: 401, message='UNAUTHORIZED', url='https://httpbin.org/basic-auth/myuser/mypassword'Python Version
Python 3.13.9aiohttp Version
Name: aiohttp
Version: 3.13.1
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author:
Author-email:
License: Apache-2.0 AND MIT
Location: /Users/mattia/miniforge3/envs/test/lib/python3.13/site-packages
Requires: aiohappyeyeballs, aiosignal, attrs, frozenlist, multidict, propcache, yarl
Required-by:multidict Version
Name: multidict
Version: 6.6.3
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache License 2.0
Location: /Users/mattia/miniforge3/envs/test/lib/python3.13/site-packages
Requires:
Required-by: aiohttp, yarlpropcache Version
Name: propcache
Version: 0.3.1
Summary: Accelerated property cache
Home-page: https://github.com/aio-libs/propcache
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Location: /Users/mattia/miniforge3/envs/test/lib/python3.13/site-packages
Requires:
Required-by: aiohttp, yarlyarl Version
Name: yarl
Version: 1.20.1
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Location: /Users/mattia/miniforge3/envs/test/lib/python3.13/site-packages
Requires: idna, multidict, propcache
Required-by: aiohttpOS
macOS
Related component
Client
Additional context
No response
Code of Conduct
- I agree to follow the aio-libs Code of Conduct