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

Compatibility with yarl==1 #2666

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion aiohttp/web_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async def cleanup(self):

# The loop over sites is intentional, an exception on gather()
# leaves self._sites in unpredictable state.
# The loop guaranties than a site is eigher deleted on success or
# The loop guaranties that a site is either deleted on success or
# still present on failure
for site in list(self._sites):
await site.stop()
Expand Down
9 changes: 5 additions & 4 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# do not use yarl.quote directly,
# use `URL(path).raw_path` instead of `quote(path)`
# Escaping of the URLs need to be consitent with the escaping done by yarl
from yarl import URL, unquote
from yarl import URL

from . import hdrs
from .abc import AbstractMatchInfo, AbstractRouter, AbstractView
Expand Down Expand Up @@ -404,7 +404,7 @@ def _match(self, path):
if match is None:
return None
else:
return {key: unquote(value, unsafe='+') for key, value in
return {key: URL(value, encoded=True).path for key, value in
match.groupdict().items()}

def raw_match(self, path):
Expand Down Expand Up @@ -534,7 +534,8 @@ async def resolve(self, request):
if method not in allowed_methods:
return None, allowed_methods

match_dict = {'filename': unquote(path[len(self._prefix)+1:])}
match_dict = {
'filename': URL(path[len(self._prefix)+1:], encoded=True).path}
return (UrlMappingMatchInfo(match_dict, self._routes[method]),
allowed_methods)

Expand All @@ -545,7 +546,7 @@ def __iter__(self):
return iter(self._routes.values())

async def _handle(self, request):
filename = unquote(request.match_info['filename'])
filename = URL(request.match_info['filename'], encoded=True).path
try:
filepath = self._directory.joinpath(filename).resolve()
if not self._follow_symlinks:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_run_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_run_app_preexisting_inet6_socket(patched_loop):
patched_loop.create_server.assert_called_with(
mock.ANY, sock=sock, backlog=128, ssl=None
)
assert "http://:::{}".format(port) in printer.call_args[0][0]
assert "http://[::]:{}".format(port) in printer.call_args[0][0]


@skip_if_no_unix_socks
Expand Down