File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,9 @@ def none2():
18
18
assert str (None ) == 'None'
19
19
assert repr (None ) == 'None'
20
20
assert type (None )() is None
21
+
22
+ assert None .__eq__ (3 ) is NotImplemented
23
+ assert None .__ne__ (3 ) is NotImplemented
24
+ assert None .__eq__ (None ) is True
25
+ assert None .__ne__ (None ) is False
26
+
Original file line number Diff line number Diff line change @@ -111,6 +111,24 @@ impl PyNoneRef {
111
111
Err ( vm. new_attribute_error ( format ! ( "{} has no attribute '{}'" , self . as_object( ) , name) ) )
112
112
}
113
113
}
114
+
115
+ #[ pymethod( name = "__eq__" ) ]
116
+ fn eq ( self , rhs : PyObjectRef , vm : & VirtualMachine ) -> PyObjectRef {
117
+ if vm. is_none ( & rhs) {
118
+ vm. ctx . new_bool ( true )
119
+ } else {
120
+ vm. ctx . not_implemented ( )
121
+ }
122
+ }
123
+
124
+ #[ pymethod( name = "__ne__" ) ]
125
+ fn ne ( self , rhs : PyObjectRef , vm : & VirtualMachine ) -> PyObjectRef {
126
+ if vm. is_none ( & rhs) {
127
+ vm. ctx . new_bool ( false )
128
+ } else {
129
+ vm. ctx . not_implemented ( )
130
+ }
131
+ }
114
132
}
115
133
116
134
pub fn init ( context : & PyContext ) {
You can’t perform that action at this time.
0 commit comments