From a54dab3b36bcf0d815b9244f52ae7bc5da08f387 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 21 Jan 2024 21:39:11 +0000 Subject: [PATCH] [PR #8049/a379e634 backport][3.9] Set cause for ClientPayloadError (#8050) **This is a backport of PR #8049 as merged into master (a379e6344432d5c033f78c2733fe69659e3cff50).** --- aiohttp/client_proto.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aiohttp/client_proto.py b/aiohttp/client_proto.py index 6225b33667c..ca99808080d 100644 --- a/aiohttp/client_proto.py +++ b/aiohttp/client_proto.py @@ -81,11 +81,11 @@ def connection_lost(self, exc: Optional[BaseException]) -> None: if self._parser is not None: try: uncompleted = self._parser.feed_eof() - except Exception: + except Exception as e: if self._payload is not None: - self._payload.set_exception( - ClientPayloadError("Response payload is not completed") - ) + exc = ClientPayloadError("Response payload is not completed") + exc.__cause__ = e + self._payload.set_exception(exc) if not self.is_eof(): if isinstance(exc, OSError):