8000 Removed unused __bool__ methods · RustPython/RustPython@ffc52ef · GitHub
[go: up one dir, main page]

Skip to content

Commit ffc52ef

Browse files
committed
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.
1 parent bdf228e commit ffc52ef

File tree

5 files changed

+0
-25
lines changed

5 files changed

+0
-25
lines changed

Lib/test/test_collections.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,12 @@ def _copy_test(self, obj):
5252
self.assertEqual(obj.data, obj_copy.data)
5353
self.assertIs(obj.test, obj_copy.test)
5454

55-
# TODO: RUSTPYTHON
56-
@unittest.expectedFailure
5755
def test_str_protocol(self):
5856
self._superset_test(UserString, str)
5957

60-
# TODO: RUSTPYTHON
61-
@unittest.expectedFailure
6258
def test_list_protocol(self):
6359
self._superset_test(UserList, list)
6460

65-
# TODO: RUSTPYTHON
66-
@unittest.expectedFailure
6761
def test_dict_protocol(self):
6862
self._superset_test(UserDict, dict)
6963

vm/src/builtins/dict.rs

Lines changed: 0 additions & 5 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,6 @@ impl PyDict {
242242
}
243243
}
244244

245-
#[pymethod(magic)]
246-
fn bool(&self) -> bool {
247-
!self.entries.is_empty()
248-
}
249-
250245
#[pymethod(magic)]
251246
pub fn len(&self) -> usize {
252247
self.entries.len()

vm/src/builtins/list.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,6 @@ impl PyList {
164164
Ok(zelf)
165165
}
166166

167-
#[pymethod(magic)]
168-
fn bool(&self) -> bool {
169-
!self.borrow_vec().is_empty()
170-
}
171-
172167
#[pymethod]
173168
fn clear(&self) {
174169
let _removed = std::mem::take(self.borrow_vec_mut().deref_mut());

vm/src/builtins/str.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,6 @@ impl PyStr {
411411
}
412412
}
413413

414-
#[pymethod(magic)]
415-
fn bool(&self) -> bool {
416-
!self.bytes.is_empty()
417-
}
418-
419414
fn _contains(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult<bool> {
420415
if let Some(needle) = needle.payload::<Self>() {
421416
Ok(self.as_str().contains(needle.as_str()))

vm/src/dictdatatype.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,6 @@ impl<T: Clone> Dict<T> {
486486
self.read().used
487487
}
488488

489-
pub fn is_empty(&self) -> bool {
490-
self.len() == 0
491-
}
492-
493489
pub fn size(&self) -> DictSize {
494490
self.read().size()
495491
}

0 commit comments

Comments
 (0)
0