Title: urllib.parse.parse_qsl does not parse empty query string with strict parsing
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, sattler
Priority: normal Keywords: patch

Created on 2021-11-22 22:35 by sattler, last changed 2021-11-22 22:39 by python-dev.

Pull Requests
URL Status Linked Edit
PR 29716 open python-dev, 2021-11-22 22:39
Messages (1)
msg406807 - (view) Author: Christian Sattler (sattler) * Date: 2021-11-22 22:35
  urllib.parse.parse_qsl('', strict_parsing=True)
yields an error:
  ValueError: bad query field: ''

The empty string '' is produced by
and also as query string by
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.
Date User Action Args
2021-11-22 22:39:32python-devsetkeywords: + patch
nosy: + python-dev

pull_requests: + pull_request27952
stage: patch review
2021-11-22 22:35:40sattlercreate