mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-119740: Remove deprecated trunc delegation (#119743)
Remove the delegation of `int` to the `__trunc__` special method: `int` will now only delegate to `__int__` and `__index__` (in that order). `__trunc__` continues to exist, but its sole purpose is to support `math.trunc`. --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
4aed319a8e
commit
f79ffc879b
11 changed files with 16 additions and 152 deletions
|
@ -386,15 +386,6 @@ class LongTest(unittest.TestCase):
|
|||
return 42
|
||||
self.assertRaises(TypeError, int, JustLong())
|
||||
|
||||
class LongTrunc:
|
||||
# __long__ should be ignored in 3.x
|
||||
def __long__(self):
|
||||
return 42
|
||||
def __trunc__(self):
|
||||
return 1729
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(int(LongTrunc()), 1729)
|
||||
|
||||
def check_float_conversion(self, n):
|
||||
# Check that int -> float conversion behaviour matches
|
||||
# that of the pure Python version above.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue