Skip to content

Commit 520e2b6

Browse files
[3.7] Fix exception causes in client.py (#4815) (#5074)
Backports the following commits to 3.7: - Fix exception causes in client.py (#4815) Co-authored-by: Ram Rachum <[email protected]>
1 parent 5ae7dfa commit 520e2b6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

aiohttp/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ async def _request(
385385

386386
try:
387387
url = URL(str_or_url)
388-
except ValueError:
389-
raise InvalidURL(str_or_url)
388+
except ValueError as e:
389+
raise InvalidURL(str_or_url) from e
390390

391391
skip_headers = set(self._skip_auto_headers)
392392
if skip_auto_headers is not None:
@@ -396,8 +396,8 @@ async def _request(
396396
if proxy is not None:
397397
try:
398398
proxy = URL(proxy)
399-
except ValueError:
400-
raise InvalidURL(proxy)
399+
except ValueError as e:
400+
raise InvalidURL(proxy) from e
401401

402402
if timeout is sentinel:
403403
real_timeout = self._timeout # type: ClientTimeout
@@ -570,8 +570,8 @@ async def _request(
570570
parsed_url = URL(
571571
r_url, encoded=not self._requote_redirect_url)
572572

573-
except ValueError:
574-
raise InvalidURL(r_url)
573+
except ValueError as e:
574+
raise InvalidURL(r_url) from e
575575

576576
scheme = parsed_url.scheme
577577
if scheme not in ('http', 'https', ''):
@@ -801,7 +801,7 @@ async def _ws_connect(
801801
resp.history,
802802
message=exc.args[0],
803803
status=resp.status,
804-
headers=resp.headers)
804+
headers=resp.headers) from exc
805805
else:
806806
compress = 0
807807
notakeover = False

0 commit comments

Comments
 (0)