File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Original file line number Diff line number Diff line change @@ -46,8 +46,6 @@ def test_complex(self):
46
46
self .assertEqual (complex (True ), 1 + 0j )
47
47
self .assertEqual (complex (True ), True )
48
48
49
- # TODO: RUSTPYTHON
50
- @unittest .expectedFailure
51
49
def test_math (self ):
52
50
self .assertEqual (+ False , 0 )
53
51
self .assertIsNot (+ False , False )
Original file line number Diff line number Diff line change 1
1
use super :: VirtualMachine ;
2
+ use crate :: stdlib:: warnings;
2
3
use crate :: {
3
4
builtins:: { PyInt , PyIntRef , PyStr , PyStrRef } ,
4
5
object:: { AsObject , PyObject , PyObjectRef , PyResult } ,
@@ -469,6 +470,17 @@ impl VirtualMachine {
469
470
}
470
471
471
472
pub fn _invert ( & self , a : & PyObject ) -> PyResult {
473
+ const STR : & str = "Bitwise inversion '~' on bool is deprecated and will be removed in Python 3.16. \
474
+ This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. \
475
+ Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int.";
476
+ if a. fast_isinstance ( self . ctx . types . bool_type ) {
477
+ warnings:: warn (
478
+ self . ctx . exceptions . deprecation_warning ,
479
+ STR . to_owned ( ) ,
480
+ 1 ,
481
+ self ,
482
+ ) ?;
483
+ }
472
484
self . get_special_method ( a, identifier ! ( self , __invert__) ) ?
473
485
. ok_or_else ( || self . new_unsupported_unary_error ( a, "unary ~" ) ) ?
474
486
. invoke ( ( ) , self )
You can’t perform that action at this time.
0 commit comments