Skip to content

unittest.util.sorted_list_difference fails to deduplicate tail elements #145546

@stefanzetzsche

Description

@stefanzetzsche

Bug report

Issue

sorted_list_difference claims in its docstring that "Duplicate elements in either input list are ignored," but when one list is exhausted before the other, the remaining elements (including duplicates) are appended without deduplication.

Reproducer

from unittest.util import sorted_list_difference

print(sorted_list_difference([], [0, 0]))
# Output: ([], [0, 0])  — expected ([], [0])

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions