@@ -15,8 +15,8 @@ use crate::{
15
15
Unconstructible , Unhashable ,
16
16
} ,
17
17
vm:: { ReprGuard , VirtualMachine } ,
18
- IdProtocol , PyClassImpl , PyComparisonValue , PyContext , PyObject , PyObjectRef , PyRef , PyResult ,
19
- PyValue , TryFromObject , TypeProtocol ,
18
+ IdProtocol , PyArithmeticValue , PyClassImpl , PyComparisonValue , PyContext , PyObject ,
19
+ PyObjectRef , PyRef , PyResult , PyValue , TryFromObject , TypeProtocol ,
20
20
} ;
21
21
use std:: { fmt, ops:: Deref } ;
22
22
@@ -485,8 +485,13 @@ impl PySet {
485
485
486
486
#[ pymethod( name = "__ror__" ) ]
487
487
#[ pymethod( magic) ]
488
- fn or ( & self , other : SetIterable , vm : & VirtualMachine ) -> PyResult < Self > {
489
- self . union ( other. iterable , vm)
488
+ fn or ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyArithmeticValue < Self > > {
489
+ if other. isinstance ( & vm. ctx . types . set_type ) || other. isinstance ( & vm. ctx . types . frozenset_type ) {
490
+ let val = PosArgs :: new ( vec ! [ ArgIterable :: try_from_object( vm, other) ?] ) ;
491
+ Ok ( PyArithmeticValue :: Implemented ( self . union ( val, vm) ?) )
492
+ } else {
493
+ Ok ( PyArithmeticValue :: NotImplemented )
494
+ }
490
495
}
491
496
492
497
#[ pymethod( name = "__rand__" ) ]
@@ -770,8 +775,13 @@ impl PyFrozenSet {
770
775
771
776
#[ pymethod( name = "__ror__" ) ]
772
777
#[ pymethod( magic) ]
773
- fn or ( & self , other : SetIterable , vm : & VirtualMachine ) -> PyResult < Self > {
774
- self . union ( other. iterable , vm)
778
+ fn or ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult < PyArithmeticValue < Self > > {
779
+ if other. isinstance ( & vm. ctx . types . set_type ) || other. isinstance ( & vm. ctx . types . frozenset_type ) {
780
+ let val = PosArgs :: new ( vec ! [ ArgIterable :: try_from_object( vm, other) ?] ) ;
781
+ Ok ( PyArithmeticValue :: Implemented ( self . union ( val, vm) ?) )
782
+ } else {
783
+ Ok ( PyArithmeticValue :: NotImplemented )
784
+ }
775
785
}
776
786
777
787
#[ pymethod( name = "__rand__" ) ]
0 commit comments