fix issue where request.args.pop removed parameters inconsistently (#2111)

This commit is contained in:
Arthur Goldberg 2021-04-12 18:26:28 +02:00 committed by GitHub
parent 5930bb67a6
commit 33a2e5bb1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -260,9 +260,12 @@ class Request:
:type errors: str :type errors: str
:return: RequestParameters :return: RequestParameters
""" """
if not self.parsed_args[ if (
(keep_blank_values, strict_parsing, encoding, errors) keep_blank_values,
]: strict_parsing,
encoding,
errors,
) not in self.parsed_args:
if self.query_string: if self.query_string:
self.parsed_args[ self.parsed_args[
(keep_blank_values, strict_parsing, encoding, errors) (keep_blank_values, strict_parsing, encoding, errors)
@ -328,9 +331,12 @@ class Request:
:type errors: str :type errors: str
:return: list :return: list
""" """
if not self.parsed_not_grouped_args[ if (
(keep_blank_values, strict_parsing, encoding, errors) keep_blank_values,
]: strict_parsing,
encoding,
errors,
) not in self.parsed_not_grouped_args:
if self.query_string: if self.query_string:
self.parsed_not_grouped_args[ self.parsed_not_grouped_args[
(keep_blank_values, strict_parsing, encoding, errors) (keep_blank_values, strict_parsing, encoding, errors)

View File

@ -244,6 +244,17 @@ def test_query_string(app):
assert request.args.getlist("test1") == ["1"] assert request.args.getlist("test1") == ["1"]
assert request.args.get("test3", default="My value") == "My value" 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 @pytest.mark.asyncio
async def test_query_string_asgi(app): async def test_query_string_asgi(app):