Fix frozenset copy to return self (#2883)

Fix frozenset copy to return zelf if called on frozenset instance
This commit is contained in:
Snowapril authored and GitHub committed 2021-08-14 15:56:22 +03:00
1 parent 9d99ea9376
commit 7cc2a5431f
2 files changed
+8 -5

No files matched your search

-2
View File
@@ -724,8 +724,6 @@ class TestFrozenSet(TestJointOps, unittest.TestCase):
results.add(hash(self.thetype(seq)))
self.assertEqual(len(results), 1)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_copy(self):
dup = self.s.copy()
self.assertEqual(id(self.s), id(dup))
+8 -3
View File
@@ -652,9 +652,14 @@ impl PyFrozenSet {
}
#[pymethod]
fn copy(&self) -> Self {
Self {
inner: self.inner.copy(),
fn copy(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyRef<Self> {
if zelf.class().is(&vm.ctx.types.frozenset_type) {
zelf
} else {
Self {
inner: zelf.inner.copy(),
}
.into_ref(vm)
}
}