-
-
Notifications
You must be signed in to change notification settings - Fork 954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Python 3.13 #2662
Support Python 3.13 #2662
Conversation
starlette/middleware/gzip.py
Outdated
@@ -42,6 +42,7 @@ 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) | |||
self.gzip_file.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@graingert Is this good enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to do it in a finally, or even better use with
with BytesIO() as buffer, GzipFile(..., buffer) as gzip_file:
await self.app(scope, receive, functools.partial(self.send_with_gzip, buffer, gzip_file))
I tried this PR as a patch for I do like @graingert’s suggestion in #2662 (comment), though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving pending #2662 (comment) being applied
* Support Python 3.13 * Use `exc_type_str` instead of `exc_type.__name__` * Close GzipFile * min changes
No description provided.