diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 9b50f0020..324fc4b3e 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -1561,8 +1561,6 @@ class BuiltinTest(unittest.TestCase): self.assertRaises(ValueError, x.translate, b"1", 1) self.assertRaises(TypeError, x.translate, b"1"*256, 1) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_construct_singletons(self): for const in None, Ellipsis, NotImplemented: tp = type(const) diff --git a/vm/src/builtins/singletons.rs b/vm/src/builtins/singletons.rs index a77f520e6..d43a822cb 100644 --- a/vm/src/builtins/singletons.rs +++ b/vm/src/builtins/singletons.rs @@ -61,6 +61,19 @@ impl PyValue for PyNotImplemented { #[pyimpl] impl PyNotImplemented { + #[pyslot] + fn tp_new(_: PyTypeRef, vm: &VirtualMachine) -> PyRef { + vm.ctx.not_implemented.clone() + } + + // TODO: As per https://bugs.python.org/issue35712, using NotImplemented + // in boolean contexts will need to raise a DeprecationWarning in 3.9 + // and, eventually, a TypeError. + #[pymethod(magic)] + fn bool(&self) -> bool { + true + } + #[pymethod(magic)] fn repr(&self) -> String { "NotImplemented".to_owned()