Skip to content

For a frozenset, frozenset.copy(), copy.copy() and frozenset() don't do a copy while copy.deepcopy() does #139397

@hyperkai

Description

@hyperkai

Bug report

Bug description:

For a frozenset, frozenset.copy(), copy.copy() and frozenset() don't do a copy which is a bug as shown below:

import copy

A = frozenset([0, 1, 2])

B = A.copy()
B = copy.copy(A)
B = frozenset(A)

print(A is B)
# True

While copy.deepcopy() does a copy properly as shown below:

import copy

A = frozenset([0, 1, 2])

B = copy.deepcopy(A)

print(A is B)
# False

In addition, for a set, set.copy(), copy.copy(), set() and copy.deepcopy() do a copy properly as shown below:

import copy

A = {0, 1, 2}

B = A.copy()
B = copy.copy(A)
B = frozenset(A)
B = copy.deepcopy(A)

print(A is B)
# False

CPython versions tested on:

3.12

Operating systems tested on:

Windows

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