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

@ -225,6 +225,11 @@ Others
It had previously raised a :exc:`DeprecationWarning` since Python 3.9. (Contributed
by Jelle Zijlstra in :gh:`118767`.)
* The :func:`int` built-in no longer delegates to
:meth:`~object.__trunc__`. Classes that want to support conversion to
integer must implement either :meth:`~object.__int__` or
:meth:`~object.__index__`. (Contributed by Mark Dickinson in :gh:`119743`.)
Porting to Python 3.14
======================