@@ -2,10 +2,12 @@ use super::{PyStrRef, PyType, PyTypeRef};
2
2
use crate :: {
3
3
class:: PyClassImpl ,
4
4
convert:: ToPyObject ,
5
+ function:: PyComparisonValue ,
5
6
protocol:: PyNumberMethods ,
6
- types:: { AsNumber , Constructor , Representable } ,
7
- Context , Py , PyObjectRef , PyPayload , PyResult , VirtualMachine ,
7
+ types:: { AsNumber , Comparable , Constructor , PyComparisonOp , Representable } ,
8
+ Context , Py , PyObject , PyObjectRef , PyPayload , PyResult , VirtualMachine ,
8
9
} ;
10
+ use rustpython_vm:: AsObject ;
9
11
10
12
#[ pyclass( module = false , name = "NoneType" ) ]
11
13
#[ derive( Debug ) ]
@@ -118,6 +120,22 @@ impl Representable for PyNotImplemented {
118
120
}
119
121
}
120
122
123
+ impl Comparable for PyNone {
124
+ #[ allow( unused_variables) ]
125
+ fn cmp (
126
+ zelf : & Py < Self > ,
127
+ other : & PyObject ,
128
+ op : PyComparisonOp ,
129
+ vm : & VirtualMachine ,
130
+ ) -> PyResult < PyComparisonValue > {
131
+ if zelf. is ( other) {
132
+ Ok ( PyComparisonValue :: Implemented ( true ) )
133
+ } else {
134
+ Ok ( PyComparisonValue :: NotImplemented )
135
+ }
136
+ }
137
+ }
138
+
121
139
pub fn init ( context : & Context ) {
122
140
PyNone :: extend_class ( context, context. types . none_type ) ;
123
141
PyNotImplemented :: extend_class ( context, context. types . not_implemented_type ) ;
0 commit comments