Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ env:
test_weakref
test_yield_from
# Python version targeted by the CI.
PYTHON_VERSION: "3.12.0"
PYTHON_VERSION: "3.12.3"

jobs:
rust_tests:
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:

- name: run rust tests
run: cargo test --workspace --exclude rustpython_wasm --verbose --features threading ${{ env.CARGO_ARGS }}
if: runner.os != 'macOS'
if: runner.os != 'macOS'
# temp skip ssl linking for Mac to avoid CI failure
- name: run rust tests (MacOS no ssl)
run: cargo test --workspace --exclude rustpython_wasm --verbose --no-default-features --features threading,stdlib,zlib,importlib,encodings,jit
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@ def __dir__(self):
# test that object has a __dir__()
self.assertEqual(sorted([].__dir__()), dir([]))

def test___ne__(self):
self.assertFalse(None.__ne__(None))
self.assertIs(None.__ne__(0), NotImplemented)
self.assertIs(None.__ne__("abc"), NotImplemented)

def test_divmod(self):
self.assertEqual(divmod(12, 7), (1, 5))
self.assertEqual(divmod(-12, 7), (-2, 2))
Expand Down
2 changes: 1 addition & 1 deletion extra_tests/snippets/builtin_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def none2():
assert None.__eq__(3) is NotImplemented
assert None.__ne__(3) is NotImplemented
assert None.__eq__(None) is True
assert None.__ne__(None) is NotImplemented
assert None.__ne__(None) is False
29 changes: 3 additions & 26 deletions vm/src/builtins/singletons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use super::{PyStrRef, PyType, PyTypeRef};
use crate::{
class::PyClassImpl,
convert::ToPyObject,
function::{PyArithmeticValue, PyComparisonValue},
protocol::PyNumberMethods,
types::{AsNumber, Comparable, Constructor, PyComparisonOp, Representable},
Context, Py, PyObject, PyObjectRef, PyPayload, PyResult, VirtualMachine,
types::{AsNumber, Constructor, Representable},
Context, Py, PyObjectRef, PyPayload, PyResult, VirtualMachine,
};

#[pyclass(module = false, name = "NoneType")]
Expand Down Expand Up @@ -43,7 +42,7 @@ impl Constructor for PyNone {
}
}

#[pyclass(with(Constructor, Comparable, AsNumber, Representable))]
#[pyclass(with(Constructor, AsNumber, Representable))]
impl PyNone {
#[pymethod(magic)]
fn bool(&self) -> bool {
Expand Down Expand Up @@ -73,28 +72,6 @@ impl AsNumber for PyNone {
}
}

impl Comparable for PyNone {
fn cmp(
_zelf: &Py<Self>,
other: &PyObject,
op: PyComparisonOp,
vm: &VirtualMachine,
) -> PyResult<PyComparisonValue> {
let value = match op {
PyComparisonOp::Eq => {
if vm.is_none(other) {
PyArithmeticValue::Implemented(true)
} else {
PyArithmeticValue::NotImplemented
}
}
_ => PyComparisonValue::NotImplemented,
};

Ok(value)
}
}

#[pyclass(module = false, name = "NotImplementedType")]
#[derive(Debug)]
pub struct PyNotImplemented;
Expand Down