diff --git a/CHANGES.rst b/CHANGES.rst index b39cf5cf2..44b54eed4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,8 @@ Unreleased quoted string values. :issue:`2907` - Debugger pin auth is synchronized across threads/processes when tracking failed entries. :issue:`2916` +- Dev server handles unexpected `SSLEOFError` due to issue in Python < 3.13. + :issue:`2926` Version 3.0.3 diff --git a/src/werkzeug/serving.py b/src/werkzeug/serving.py index 859f9aacb..4faf9262c 100644 --- a/src/werkzeug/serving.py +++ b/src/werkzeug/serving.py @@ -37,6 +37,12 @@ try: import ssl + + connection_dropped_errors: tuple[type[Exception], ...] = ( + ConnectionError, + socket.timeout, + ssl.SSLEOFError, + ) except ImportError: class _SslDummy: @@ -47,6 +53,7 @@ def __getattr__(self, name: str) -> t.Any: ) ssl = _SslDummy() # type: ignore + connection_dropped_errors = (ConnectionError, socket.timeout) _log_add_style = True @@ -361,7 +368,7 @@ def execute(app: WSGIApplication) -> None: try: execute(self.server.app) - except (ConnectionError, socket.timeout) as e: + except connection_dropped_errors as e: self.connection_dropped(e, environ) except Exception as e: if self.server.passthrough_errors: