From dd06516d1cdc5fdbe8072c8986d00195287afe93 Mon Sep 17 00:00:00 2001 From: Ankit Goel Date: Sun, 15 Sep 2024 04:42:29 +0100 Subject: [PATCH] Deprecate delegating int() to __trunc__ --- Lib/test/test_long.py | 2 -- vm/src/protocol/number.rs | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 6bbb44a69..6d6923281 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -378,8 +378,6 @@ class LongTest(unittest.TestCase): self.assertRaises(ValueError, int, '\u3053\u3093\u306b\u3061\u306f') - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_conversion(self): class JustLong: diff --git a/vm/src/protocol/number.rs b/vm/src/protocol/number.rs index 0dbb5ca8d..08d42027e 100644 --- a/vm/src/protocol/number.rs +++ b/vm/src/protocol/number.rs @@ -63,13 +63,12 @@ impl PyObject { } else if let Some(i) = self.to_number().int(vm).or_else(|| self.try_index_opt(vm)) { i } else if let Ok(Some(f)) = vm.get_special_method(self, identifier!(vm, __trunc__)) { - // TODO: Deprecate in 3.11 - // warnings::warn( - // vm.ctx.exceptions.deprecation_warning.clone(), - // "The delegation of int() to __trunc__ is deprecated.".to_owned(), - // 1, - // vm, - // )?; + warnings::warn( + vm.ctx.exceptions.deprecation_warning, + "The delegation of int() to __trunc__ is deprecated.".to_owned(), + 1, + vm, + )?; let ret = f.invoke((), vm)?; ret.try_index(vm).map_err(|_| { vm.new_type_error(format!(