Deprecate delegating int() to __trunc__

This commit is contained in:
Ankit Goel authored and Jeong, YunWon committed 2024-09-17 16:06:09 +09:00
1 parent 8066f36a4e
commit dd06516d1c
2 files changed
+6 -9

No files matched your search

-2
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:
+6 -7
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!(