From d93150cbdd77b727712035e3ccdefe24a0b4e8b6 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Fri, 12 Jun 2020 13:09:14 +0300 Subject: [PATCH] Fix exception causes in client.py --- aiohttp/client.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/aiohttp/client.py b/aiohttp/client.py index 36044b5056f..de98110b31e 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -345,8 +345,8 @@ async def _request( try: url = URL(str_or_url) - except ValueError: - raise InvalidURL(str_or_url) + except ValueError as e: + raise InvalidURL(str_or_url) from e skip_headers = set(self._skip_auto_headers) if skip_auto_headers is not None: @@ -356,8 +356,8 @@ async def _request( if proxy is not None: try: proxy = URL(proxy) - except ValueError: - raise InvalidURL(proxy) + except ValueError as e: + raise InvalidURL(proxy) from e if timeout is sentinel: real_timeout = self._timeout # type: ClientTimeout @@ -525,8 +525,8 @@ async def _request( r_url = URL( r_url, encoded=not self._requote_redirect_url) - except ValueError: - raise InvalidURL(r_url) + except ValueError as e: + raise InvalidURL(r_url) from e scheme = r_url.scheme if scheme not in ('http', 'https', ''): @@ -773,7 +773,7 @@ async def _ws_connect( resp.history, message=exc.args[0], status=resp.status, - headers=resp.headers) + headers=resp.headers) from exc else: compress = 0 notakeover = False