Skip to content
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

Change dumps to AnyStr #2193

Merged
merged 6 commits into from
Jul 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sanic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from types import SimpleNamespace
from typing import (
Any,
AnyStr,
Awaitable,
Callable,
Coroutine,
Expand Down Expand Up @@ -138,7 +139,7 @@ def __init__(
log_config: Optional[Dict[str, Any]] = None,
configure_logging: bool = True,
register: Optional[bool] = None,
dumps: Optional[Callable[..., str]] = None,
dumps: Optional[Callable[..., AnyStr]] = None,
) -> None:
super().__init__(name=name)

Expand Down Expand Up @@ -193,7 +194,7 @@ def __init__(
self.router.ctx.app = self

if dumps:
BaseHTTPResponse._dumps = dumps
BaseHTTPResponse._dumps = dumps # type: ignore

@property
def loop(self):
Expand Down Expand Up @@ -737,15 +738,14 @@ async def handle_request(self, request: Request):
request.route = route

if (
request.stream.request_body # type: ignore
request.stream
and request.stream.request_body
and not route.ctx.ignore_body
):

if hasattr(handler, "is_stream"):
# Streaming handler: lift the size limit
request.stream.request_max_size = float( # type: ignore
"inf"
)
request.stream.request_max_size = float("inf")
else:
# Non-streaming handler: preload body
await request.receive_body()
Expand Down