diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 0bb570ced..fac946039 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: "actions/checkout@v4" diff --git a/pyproject.toml b/pyproject.toml index b1271db8d..f2721c870 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Internet :: WWW/HTTP", ] dependencies = [ diff --git a/starlette/middleware/errors.py b/starlette/middleware/errors.py index e9eba62b0..3fc4a4402 100644 --- a/starlette/middleware/errors.py +++ b/starlette/middleware/errors.py @@ -2,6 +2,7 @@ import html import inspect +import sys import traceback import typing @@ -237,11 +238,13 @@ def generate_html(self, exc: Exception, limit: int = 7) -> str: exc_html += self.generate_frame_html(frame, is_collapsed) is_collapsed = True + if sys.version_info >= (3, 13): # pragma: no cover + exc_type_str = traceback_obj.exc_type_str + else: # pragma: no cover + exc_type_str = traceback_obj.exc_type.__name__ + # escape error class and text - error = ( - f"{html.escape(traceback_obj.exc_type.__name__)}: " - f"{html.escape(str(traceback_obj))}" - ) + error = f"{html.escape(exc_type_str)}: {html.escape(str(traceback_obj))}" return TEMPLATE.format(styles=STYLES, js=JS, error=error, exc_html=exc_html) diff --git a/starlette/middleware/gzip.py b/starlette/middleware/gzip.py index cbb0f4a5b..0579e0410 100644 --- a/starlette/middleware/gzip.py +++ b/starlette/middleware/gzip.py @@ -41,7 +41,8 @@ def __init__(self, app: ASGIApp, minimum_size: int, compresslevel: int = 9) -> N async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: self.send = send - await self.app(scope, receive, self.send_with_gzip) + with self.gzip_buffer, self.gzip_file: + await self.app(scope, receive, self.send_with_gzip) async def send_with_gzip(self, message: Message) -> None: message_type = message["type"]