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:
Mark Dickinson 2024-06-02 10:16:49 +01:00 committed by GitHub
parent 4aed319a8e
commit f79ffc879b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 16 additions and 152 deletions

View file

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