[New-bugs-announce] [issue45874] urllib.parse.parse_qsl does not parse empty query string with strict parsing

Christian Sattler report at bugs.python.org
Mon Nov 22 17:35:40 EST 2021


New submission from Christian Sattler <sattler.christian at web.de>:

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.

----------
components: Library (Lib)
messages: 406807
nosy: sattler
priority: normal
severity: normal
status: open
title: urllib.parse.parse_qsl does not parse empty query string with strict parsing
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45874>
_______________________________________


More information about the New-bugs-announce mailing list