@@ -264,6 +264,7 @@ mod tests {
264
264
use super :: * ;
265
265
use crate :: ffi;
266
266
use crate :: { py_result_ext:: PyResultExt , types:: PyDict , types:: PyType } ;
267
+ use std:: ptr;
267
268
268
269
fn get_type ( py : Python < ' _ > ) -> PyResult < Bound < ' _ , PyType > > {
269
270
let globals = PyDict :: new ( py) ;
@@ -349,8 +350,10 @@ mod tests {
349
350
let obj = obj. unwrap ( ) ;
350
351
351
352
assert ! ( obj. is_some( ) ) ;
352
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( )
353
- && obj. is_exact_instance( & class) ) ) ;
353
+ assert ! (
354
+ obj. map_or( false , |obj| ptr:: eq( obj. as_ptr( ) , object. as_ptr( ) )
355
+ && obj. is_exact_instance( & class) )
356
+ ) ;
354
357
}
355
358
356
359
drop ( object) ;
@@ -381,8 +384,10 @@ mod tests {
381
384
let obj = unsafe { reference. upgrade_as_unchecked :: < PyAny > ( ) } ;
382
385
383
386
assert ! ( obj. is_some( ) ) ;
384
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( )
385
- && obj. is_exact_instance( & class) ) ) ;
387
+ assert ! (
388
+ obj. map_or( false , |obj| ptr:: eq( obj. as_ptr( ) , object. as_ptr( ) )
389
+ && obj. is_exact_instance( & class) )
390
+ ) ;
386
391
}
387
392
388
393
drop ( object) ;
@@ -439,6 +444,7 @@ mod tests {
439
444
mod pyo3_pyclass {
440
445
use super :: * ;
441
446
use crate :: { pyclass, Py } ;
447
+ use std:: ptr;
442
448
443
449
#[ pyclass( weakref, crate = "crate" ) ]
444
450
struct WeakrefablePyClass { }
@@ -520,7 +526,7 @@ mod tests {
520
526
let obj = obj. unwrap ( ) ;
521
527
522
528
assert ! ( obj. is_some( ) ) ;
523
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( ) ) ) ;
529
+ assert ! ( obj. map_or( false , |obj| ptr :: eq ( obj. as_ptr( ) , object. as_ptr( ) ) ) ) ;
524
530
}
525
531
526
532
drop ( object) ;
@@ -548,7 +554,7 @@ mod tests {
548
554
let obj = unsafe { reference. upgrade_as_unchecked :: < WeakrefablePyClass > ( ) } ;
549
555
550
556
assert ! ( obj. is_some( ) ) ;
551
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( ) ) ) ;
557
+ assert ! ( obj. map_or( false , |obj| ptr :: eq ( obj. as_ptr( ) , object. as_ptr( ) ) ) ) ;
552
558
}
553
559
554
560
drop ( object) ;
@@ -611,6 +617,7 @@ mod tests {
611
617
use super :: * ;
612
618
use crate :: ffi;
613
619
use crate :: { py_result_ext:: PyResultExt , types:: PyDict , types:: PyType } ;
620
+ use std:: ptr;
614
621
615
622
fn get_type ( py : Python < ' _ > ) -> PyResult < Bound < ' _ , PyType > > {
616
623
let globals = PyDict :: new ( py) ;
@@ -687,8 +694,10 @@ mod tests {
687
694
let obj = obj. unwrap ( ) ;
688
695
689
696
assert ! ( obj. is_some( ) ) ;
690
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( )
691
- && obj. is_exact_instance( & class) ) ) ;
697
+ assert ! (
698
+ obj. map_or( false , |obj| ptr:: eq( obj. as_ptr( ) , object. as_ptr( ) )
699
+ && obj. is_exact_instance( & class) )
700
+ ) ;
692
701
}
693
702
694
703
drop ( object) ;
@@ -719,8 +728,10 @@ mod tests {
719
728
let obj = unsafe { reference. upgrade_as_unchecked :: < PyAny > ( ) } ;
720
729
721
730
assert ! ( obj. is_some( ) ) ;
722
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( )
723
- && obj. is_exact_instance( & class) ) ) ;
731
+ assert ! (
732
+ obj. map_or( false , |obj| ptr:: eq( obj. as_ptr( ) , object. as_ptr( ) )
733
+ && obj. is_exact_instance( & class) )
734
+ ) ;
724
735
}
725
736
726
737
drop ( object) ;
@@ -778,6 +789,7 @@ mod tests {
778
789
mod pyo3_pyclass {
779
790
use super :: * ;
780
791
use crate :: { pyclass, pymethods, Py } ;
792
+ use std:: ptr;
781
793
782
794
#[ pyclass( weakref, crate = "crate" ) ]
783
795
struct WeakrefablePyClass { }
@@ -854,7 +866,7 @@ mod tests {
854
866
let obj = obj. unwrap ( ) ;
855
867
856
868
assert ! ( obj. is_some( ) ) ;
857
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( ) ) ) ;
869
+ assert ! ( obj. map_or( false , |obj| ptr :: eq ( obj. as_ptr( ) , object. as_ptr( ) ) ) ) ;
858
870
}
859
871
860
872
drop ( object) ;
@@ -882,7 +894,7 @@ mod tests {
882
894
let obj = unsafe { reference. upgrade_as_unchecked :: < WeakrefablePyClass > ( ) } ;
883
895
884
896
assert ! ( obj. is_some( ) ) ;
885
- assert ! ( obj. map_or( false , |obj| obj. as_ptr( ) == object. as_ptr( ) ) ) ;
897
+ assert ! ( obj. map_or( false , |obj| ptr :: eq ( obj. as_ptr( ) , object. as_ptr( ) ) ) ) ;
886
898
}
887
899
888
900
drop ( object) ;
0 commit comments