Merge pull request #2981 from DimitrisJim/deque_subclass_copy

Return subclass on deque copy.
This commit is contained in:
Jeong YunWon
2021-08-28 11:02:15 +09:00
committed by GitHub
2 changed files with 6 additions and 7 deletions

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')

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]