We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa40a13 commit 10327b5Copy full SHA for 10327b5
vm/src/builtins/singletons.rs
@@ -1,7 +1,10 @@
1
use super::{PyType, PyTypeRef};
2
use crate::{
3
- class::PyClassImpl, convert::ToPyObject, types::Constructor, Context, Py, PyObjectRef,
4
- PyPayload, PyResult, VirtualMachine,
+ class::PyClassImpl,
+ convert::ToPyObject,
5
+ protocol::PyNumberMethods,
6
+ types::{AsNumber, Constructor},
7
+ Context, Py, PyObjectRef, PyPayload, PyResult, VirtualMachine,
8
};
9
10
#[pyclass(module = false, name = "NoneType")]
@@ -39,7 +42,7 @@ impl Constructor for PyNone {
39
42
}
40
43
41
44
-#[pyimpl(with(Constructor))]
45
+#[pyimpl(with(Constructor, AsNumber))]
46
impl PyNone {
47
#[pymethod(magic)]
48
fn repr(&self) -> String {
@@ -52,6 +55,13 @@ impl PyNone {
52
55
53
56
54
57
58
+impl AsNumber for PyNone {
59
+ const AS_NUMBER: PyNumberMethods = PyNumberMethods {
60
+ boolean: Some(|_number, _vm| Ok(false)),
61
+ ..PyNumberMethods::NOT_IMPLEMENTED
62
+ };
63
+}
64
+
65
#[pyclass(module = false, name = "NotImplementedType")]
66
#[derive(Debug)]
67
pub struct PyNotImplemented;
0 commit comments