diff --git a/starlette/endpoints.py b/starlette/endpoints.py index 1071fc354..2504dd84d 100644 --- a/starlette/endpoints.py +++ b/starlette/endpoints.py @@ -71,7 +71,7 @@ async def dispatch(self) -> None: break except Exception as exc: close_code = status.WS_1011_INTERNAL_ERROR - raise exc from None + raise exc finally: await self.on_disconnect(websocket, close_code) diff --git a/starlette/exceptions.py b/starlette/exceptions.py index f7ad231f6..a99177a02 100644 --- a/starlette/exceptions.py +++ b/starlette/exceptions.py @@ -79,7 +79,7 @@ async def sender(message: Message) -> None: handler = self._lookup_exception_handler(exc) if handler is None: - raise exc from None + raise exc if response_started: msg = "Caught handled exception, but response already started." diff --git a/starlette/middleware/errors.py b/starlette/middleware/errors.py index 4217185e8..30f5570ca 100644 --- a/starlette/middleware/errors.py +++ b/starlette/middleware/errors.py @@ -178,7 +178,7 @@ async def _send(message: Message) -> None: # We always continue to raise the exception. # This allows servers to log the error, or allows test clients # to optionally raise the error within the test case. - raise exc from None + raise exc def format_line( self, index: int, line: str, frame_lineno: int, frame_index: int diff --git a/starlette/testclient.py b/starlette/testclient.py index 1d5e90dc8..bb4b75fde 100644 --- a/starlette/testclient.py +++ b/starlette/testclient.py @@ -240,7 +240,7 @@ async def send(message: Message) -> None: loop.run_until_complete(self.app(scope, receive, send)) except BaseException as exc: if self.raise_server_exceptions: - raise exc from None + raise exc if self.raise_server_exceptions: assert response_started, "TestClient did not receive any response."