mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Deprecate delegating int() to __trunc__
This commit is contained in:
committed by
Jeong, YunWon
parent
8066f36a4e
commit
dd06516d1c
2
Lib/test/test_long.py
vendored
2
Lib/test/test_long.py
vendored
@@ -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:
|
||||
|
||||
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user