Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
150d75b7c6 |
12
.github/FUNDING.yml
vendored
12
.github/FUNDING.yml
vendored
@@ -1,12 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: sanic-org # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -1 +1 @@
|
||||
__version__ = "20.12.4"
|
||||
__version__ = "20.12.0"
|
||||
|
||||
30
sanic/app.py
30
sanic/app.py
@@ -12,7 +12,6 @@ from ssl import Purpose, SSLContext, create_default_context
|
||||
from traceback import format_exc
|
||||
from typing import Any, Dict, Optional, Type, Union
|
||||
from urllib.parse import urlencode, urlunparse
|
||||
from warnings import warn
|
||||
|
||||
from sanic import reloader_helpers
|
||||
from sanic.asgi import ASGIApp
|
||||
@@ -51,7 +50,6 @@ class Sanic:
|
||||
strict_slashes=False,
|
||||
log_config=None,
|
||||
configure_logging=True,
|
||||
register=None,
|
||||
):
|
||||
|
||||
# Get name from previous stack frame
|
||||
@@ -90,11 +88,7 @@ class Sanic:
|
||||
# Register alternative method names
|
||||
self.go_fast = self.run
|
||||
|
||||
if register is not None:
|
||||
self.config.REGISTER = register
|
||||
|
||||
if self.config.REGISTER:
|
||||
self.__class__.register_app(self)
|
||||
self.__class__.register_app(self)
|
||||
|
||||
@property
|
||||
def loop(self):
|
||||
@@ -495,7 +489,9 @@ class Sanic:
|
||||
websocket_handler = partial(
|
||||
self._websocket_handler, handler, subprotocols=subprotocols
|
||||
)
|
||||
websocket_handler.__name__ = handler.__name__
|
||||
websocket_handler.__name__ = (
|
||||
"websocket_handler_" + handler.__name__
|
||||
)
|
||||
routes.extend(
|
||||
self.router.add(
|
||||
uri=uri,
|
||||
@@ -746,24 +742,6 @@ class Sanic:
|
||||
kw.update(name=view_name)
|
||||
|
||||
uri, route = self.router.find_route_by_view_name(view_name, **kw)
|
||||
|
||||
# TODO(laggardkernel): this fix should be removed in v21.3.
|
||||
# Try again without the unnecessary prefix "websocket_handler_",
|
||||
# which was added by accident on non-blueprint handlers. GH-2021
|
||||
if not (uri and route) and view_name.startswith("websocket_handler_"):
|
||||
view_name = view_name[18:]
|
||||
uri, route = self.router.find_route_by_view_name(view_name, **kw)
|
||||
if uri and route:
|
||||
warn(
|
||||
"The bug of adding unnecessary `websocket_handler_` "
|
||||
"prefix in param `view_name` for non-blueprint handlers "
|
||||
"is fixed. This backward support will be removed in "
|
||||
"v21.3. Please update `Sanic.url_for()` callings in your "
|
||||
"code soon.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
if not (uri and route):
|
||||
raise URLBuildError(
|
||||
f"Endpoint with name `{view_name}` was not found"
|
||||
|
||||
@@ -40,7 +40,6 @@ DEFAULT_CONFIG = {
|
||||
"PROXIES_COUNT": None,
|
||||
"FORWARDED_FOR_HEADER": "X-Forwarded-For",
|
||||
"FALLBACK_ERROR_FORMAT": "html",
|
||||
"REGISTER": True,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -265,12 +265,9 @@ class Request:
|
||||
:type errors: str
|
||||
:return: RequestParameters
|
||||
"""
|
||||
if (
|
||||
keep_blank_values,
|
||||
strict_parsing,
|
||||
encoding,
|
||||
errors,
|
||||
) not in self.parsed_args:
|
||||
if not self.parsed_args[
|
||||
(keep_blank_values, strict_parsing, encoding, errors)
|
||||
]:
|
||||
if self.query_string:
|
||||
self.parsed_args[
|
||||
(keep_blank_values, strict_parsing, encoding, errors)
|
||||
@@ -324,12 +321,9 @@ class Request:
|
||||
:type errors: str
|
||||
:return: list
|
||||
"""
|
||||
if (
|
||||
keep_blank_values,
|
||||
strict_parsing,
|
||||
encoding,
|
||||
errors,
|
||||
) not in self.parsed_not_grouped_args:
|
||||
if not self.parsed_not_grouped_args[
|
||||
(keep_blank_values, strict_parsing, encoding, errors)
|
||||
]:
|
||||
if self.query_string:
|
||||
self.parsed_not_grouped_args[
|
||||
(keep_blank_values, strict_parsing, encoding, errors)
|
||||
|
||||
3
setup.py
3
setup.py
@@ -57,8 +57,7 @@ setup_kwargs = {
|
||||
"author": "Sanic Community",
|
||||
"author_email": "admhpkns@gmail.com",
|
||||
"description": (
|
||||
"A web server and web framework that's written to go fast. "
|
||||
"Build fast. Run fast."
|
||||
"A web server and web framework that's written to go fast. Build fast. Run fast."
|
||||
),
|
||||
"long_description": long_description,
|
||||
"packages": ["sanic"],
|
||||
|
||||
@@ -3,7 +3,6 @@ import logging
|
||||
import sys
|
||||
|
||||
from inspect import isawaitable
|
||||
from os import environ
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
@@ -291,7 +290,6 @@ def test_app_registry_name_reuse():
|
||||
with pytest.raises(SanicException):
|
||||
Sanic("test")
|
||||
Sanic.test_mode = True
|
||||
Sanic("test")
|
||||
|
||||
|
||||
def test_app_registry_retrieval():
|
||||
@@ -308,17 +306,3 @@ def test_get_app_does_not_exist_force_create():
|
||||
assert isinstance(
|
||||
Sanic.get_app("does-not-exist", force_create=True), Sanic
|
||||
)
|
||||
|
||||
|
||||
def test_app_no_registry():
|
||||
Sanic("no-register", register=False)
|
||||
with pytest.raises(SanicException):
|
||||
Sanic.get_app("no-register")
|
||||
|
||||
|
||||
def test_app_no_registry_env():
|
||||
environ["SANIC_REGISTER"] = "False"
|
||||
Sanic("no-register")
|
||||
with pytest.raises(SanicException):
|
||||
Sanic.get_app("no-register")
|
||||
del environ["SANIC_REGISTER"]
|
||||
|
||||
@@ -289,17 +289,6 @@ def test_query_string(app):
|
||||
assert request.args.getlist("test1") == ["1"]
|
||||
assert request.args.get("test3", default="My value") == "My value"
|
||||
|
||||
def test_popped_stays_popped(app):
|
||||
@app.route("/")
|
||||
async def handler(request):
|
||||
return text("OK")
|
||||
|
||||
request, response = app.test_client.get(
|
||||
"/", params=[("test1", "1")]
|
||||
)
|
||||
|
||||
assert request.args.pop("test1") == ["1"]
|
||||
assert "test1" not in request.args
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_query_string_asgi(app):
|
||||
|
||||
@@ -348,13 +348,3 @@ def test_methodview_naming(methodview_app):
|
||||
|
||||
assert viewone_url == "/view_one"
|
||||
assert viewtwo_url == "/view_two"
|
||||
|
||||
|
||||
def test_url_for_with_websocket_handlers(app):
|
||||
# Test for a specific bugfix in GH-2021
|
||||
@app.websocket("/ws")
|
||||
async def my_handler(request, ws):
|
||||
pass
|
||||
|
||||
assert app.url_for("my_handler") == "/ws"
|
||||
assert app.url_for("websocket_handler_my_handler") == "/ws"
|
||||
|
||||
Reference in New Issue
Block a user