Skip to content

set(r) mutates r #127493

@pvm2

Description

@pvm2

Bug report

Bug description:

r = [('a',)]
r = filter(lambda x:x[-1] != '.', r)
print(sum(1 for _ in r) == len(set(r))) # -> False
set(r)
print(sum(1 for _ in r) == len(set(r))) # -> True

Happens on Windows 3.13.0 and Python 3.14.0a2+ (heads/main:7ea523f47cd, Dec 2 2024, 00:11:08) [GCC 11.4.0] on linux (with WSL Ubuntu). I discovered this on Windows 3.12.(5 I think) so maybe it's been around for longer.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions