mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Fix frozenset copy to return self (#2883)
Fix frozenset copy to return zelf if called on frozenset instance
This commit is contained in:
1 parent
9d99ea9376
commit
7cc2a5431f
2 files changed
+8
-5
No files matched your search
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user