Return subclass on copy.

This commit is contained in:
jfh committed 2021-08-27 20:47:41 +03:00
1 parent d6dc0957df
commit 2b5251a4ec
2 files changed
+6 -7

No files matched your search

-2
View File
@@ -833,8 +833,6 @@ class TestSubclass(unittest.TestCase):
d.clear()
self.assertEqual(len(d), 0)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_copy_pickle(self):
d = Deque('abc')
+6 -5
View File
@@ -174,12 +174,13 @@ mod _collections {
#[pymethod(magic)]
#[pymethod]
fn copy(&self) -> Self {
PyDeque {
deque: PyRwLock::new(self.borrow_deque().clone()),
maxlen: self.maxlen,
state: AtomicCell::new(self.state.load()),
fn copy(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyRef<Self>> {
Self {
deque: PyRwLock::new(zelf.borrow_deque().clone()),
maxlen: zelf.maxlen,
state: AtomicCell::new(zelf.state.load()),
}
.into_ref_with_type(vm, zelf.clone_class())
}
#[pymethod]