Feature
I'm trying to fix @unittest.expectedFailure test_inplace_on_self in file test_set.py.
def test_inplace_on_self(self):
t = self.s.copy()
t |= t
self.assertEqual(t, self.s)
t &= t
self.assertEqual(t, self.s). -> FAIL
t -= t
self.assertEqual(t, self.thetype()). -> FAIL
t = self.s.copy()
t ^= t
self.assertEqual(t, self.thetype())
I found the two operator fail.
&= and -= is not work correctly.
[ &= ]
>>>>> s = set({'a', 'b', 'c'})
>>>>> s &= s
>>>>> s
set()
>>> s = set({'a', 'b', 'c'})
>>> s &= s
>>> s
{'b', 'c', 'a'}
[ -= ]
>>>>> s = set({'a', 'b', 'c'})
>>>>> s -= s
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: set changed size during iteration
Maybe the points to start
#[pymethod(magic)]
fn iand(zelf: PyRef<Self>, set: AnySet, vm: &VirtualMachine) -> PyResult<PyRef<Self>> {
zelf.inner
.intersection_update(std::iter::once(set.into_iterable(vm)?), vm)?;
Ok(zelf)
}
#[pymethod(magic)]
fn isub(zelf: PyRef<Self>, set: AnySet, vm: &VirtualMachine) -> PyResult<PyRef<Self>> {
zelf.inner
.difference_update(set.into_iterable_iter(vm)?, vm)?;
Ok(zelf)
}
Python Documentation
CPython Method
Reactions are currently unavailable
Feature
I'm trying to fix @unittest.expectedFailure test_inplace_on_self in file test_set.py.
def test_inplace_on_self(self): t = self.s.copy() t |= t self.assertEqual(t, self.s) t &= t self.assertEqual(t, self.s). -> FAIL t -= t self.assertEqual(t, self.thetype()). -> FAIL t = self.s.copy() t ^= t self.assertEqual(t, self.thetype())I found the two operator fail.
&= and -= is not work correctly.
[ &= ]
>>>>> s = set({'a', 'b', 'c'}) >>>>> s &= s >>>>> s set()>>> s = set({'a', 'b', 'c'}) >>> s &= s >>> s {'b', 'c', 'a'}[ -= ]
>>>>> s = set({'a', 'b', 'c'}) >>>>> s -= s Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: set changed size during iterationMaybe the points to start
#[pymethod(magic)] fn iand(zelf: PyRef<Self>, set: AnySet, vm: &VirtualMachine) -> PyResult<PyRef<Self>> { zelf.inner .intersection_update(std::iter::once(set.into_iterable(vm)?), vm)?; Ok(zelf) }#[pymethod(magic)] fn isub(zelf: PyRef<Self>, set: AnySet, vm: &VirtualMachine) -> PyResult<PyRef<Self>> { zelf.inner .difference_update(set.into_iterable_iter(vm)?, vm)?; Ok(zelf) }Python Documentation
CPython Method
&=
https://github.com/python/cpython/blob/75a6441718dcbc65d993c9544e67e25bef120e82/Objects/setobject.c#L1181-L1261
-=
https://github.com/python/cpython/blob/75a6441718dcbc65d993c9544e67e25bef120e82/Objects/setobject.c#L1406-L1461