Removed unused __bool__ methods

Python does not define `list().__bool__`, `dict().__bool__`, and
`str().__bool__`, and some tests were failing because they were
defined.
I could not find any references to them and deleting them doesn't
seem to break anything.
This commit is contained in:
Daniel Chiquito
2024-02-09 16:33:36 -05:00
parent bdf228eb42
commit ffc52ef87c
5 changed files with 0 additions and 25 deletions

View File

@@ -52,18 +52,12 @@ class TestUserObjects(unittest.TestCase):
self.assertEqual(obj.data, obj_copy.data)
self.assertIs(obj.test, obj_copy.test)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_str_protocol(self):
self._superset_test(UserString, str)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_list_protocol(self):
self._superset_test(UserList, list)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_dict_protocol(self):
self._superset_test(UserDict, dict)

View File

@@ -242,11 +242,6 @@ impl PyDict {
}
}
#[pymethod(magic)]
fn bool(&self) -> bool {
!self.entries.is_empty()
}
#[pymethod(magic)]
pub fn len(&self) -> usize {
self.entries.len()

View File

@@ -164,11 +164,6 @@ impl PyList {
Ok(zelf)
}
#[pymethod(magic)]
fn bool(&self) -> bool {
!self.borrow_vec().is_empty()
}
#[pymethod]
fn clear(&self) {
let _removed = std::mem::take(self.borrow_vec_mut().deref_mut());

View File

@@ -411,11 +411,6 @@ impl PyStr {
}
}
#[pymethod(magic)]
fn bool(&self) -> bool {
!self.bytes.is_empty()
}
fn _contains(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult<bool> {
if let Some(needle) = needle.payload::<Self>() {
Ok(self.as_str().contains(needle.as_str()))

View File

@@ -486,10 +486,6 @@ impl<T: Clone> Dict<T> {
self.read().used
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
pub fn size(&self) -> DictSize {
self.read().size()
}