Skip to content

Deprecate support of false values in urllib.parse.parse_qsl() #116897

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

urllib.parse.parse_qsl() returns [] for any false value. There were no tests for this, so it was broken by accident in #115771 and restored in #116764.

Historically, the special case was needed to circumvent the fact that ''.split('&') returns [''] instead of []. parse_qsl('') and parse_qsl(b'') should return []. But zero numbers and empty sequences (like parse_qsl(0) and parse_qsl([])) should be errors. So I propose to deprecate the current behavior for general false values and make them errors in future.

There is an open question about None. There is a code in the wild that expects parse_qsl(None) to work. Although it is not difficult to add workarounds for this, it may be more convenient if None is accepted as a valid value.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions