Deprecate delegating int() to __trunc__

This commit is contained in:
Ankit Goel
2024-09-15 04:42:29 +01:00
committed by Jeong, YunWon
parent 8066f36a4e
commit dd06516d1c
2 changed files with 6 additions and 9 deletions

View File

@@ -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:

View File

@@ -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!(