Open b0f9f430-9789-4099-bf6c-e8fc6a2b058d opened 2 years ago
Calling urllib.parse.parse_qsl('', strict_parsing=True) yields an error: ValueError: bad query field: ''
The empty string '' is produced by urllib.parse.urlencode({}) and also as query string by urllib.parse.urlsplit('http://example.org/') so it should be accepted by urllib.parse.parse_qsl with strict parsing.
The problem is that parse_qsl(qs, ...) cannot distinguish between zero and one query arguments. The call to qs.split(separator) returns the non-empty list [''] for qs empty, which means one query argument. However, in this case, we want the other semantics.
New changeset e6fe10d34096a23be7d26271cf6aba429313b01d by Christian Sattler in branch 'main': bpo-45874: Handle empty query string correctly in urllib.parse.parse_qsl (bpo-29716) https://github.com/python/cpython/commit/e6fe10d34096a23be7d26271cf6aba429313b01d
@asvetlov Issue seems to resolved. We can close the issue.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at = None created_at =
labels = ['type-bug', 'library', '3.10']
title = 'urllib.parse.parse_qsl does not parse empty query string with strict parsing'
updated_at =
user = 'https://github.com/sattlerc'
```
bugs.python.org fields:
```python
activity =
actor = 'asvetlov'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation =
creator = 'sattler'
dependencies = []
files = []
hgrepos = []
issue_num = 45874
keywords = ['patch']
message_count = 2.0
messages = ['406807', '408368']
nosy_count = 3.0
nosy_names = ['asvetlov', 'python-dev', 'sattler']
pr_nums = ['29716']
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue45874'
versions = ['Python 3.10']
```