diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-06-01 21:05:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-01 21:05:48 (GMT) |
commit | bdbad71b9def0b86433de12cecca022eee91bd9f (patch) | |
tree | 147c8a3e08454a95e0e4900388d88f7b65430f63 /Doc/whatsnew/3.8.rst | |
parent | 1a4d9ffa1aecd7e750195f2be06d3d16c7a3a88f (diff) | |
download | cpython-bdbad71b9def0b86433de12cecca022eee91bd9f.zip cpython-bdbad71b9def0b86433de12cecca022eee91bd9f.tar.gz cpython-bdbad71b9def0b86433de12cecca022eee91bd9f.tar.bz2 |
bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108)
Diffstat (limited to 'Doc/whatsnew/3.8.rst')
-rw-r--r-- | Doc/whatsnew/3.8.rst | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 4c5a9bb..591b454 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -250,6 +250,12 @@ Other Language Changes compatible with the existing :meth:`float.as_integer_ratio` method. (Contributed by Lisa Roach in :issue:`33073`.) +* Constructors of :class:`int`, :class:`float` and :class:`complex` will now + use the :meth:`~object.__index__` special method, if available and the + corresponding method :meth:`~object.__int__`, :meth:`~object.__float__` + or :meth:`~object.__complex__` is not available. + (Contributed by Serhiy Storchaka in :issue:`20092`.) + * Added support of ``\N{name}`` escapes in :mod:`regular expressions <re>`. (Contributed by Jonathan Eunice and Serhiy Storchaka in :issue:`30688`.) @@ -868,7 +874,10 @@ Build and C API Changes ``__index__()`` method (like :class:`~decimal.Decimal` and :class:`~fractions.Fraction`). :c:func:`PyNumber_Check` will now return ``1`` for objects implementing ``__index__()``. - (Contributed by Serhiy Storchaka in :issue:`36048`.) + :c:func:`PyNumber_Long`, :c:func:`PyNumber_Float` and + :c:func:`PyFloat_AsDouble` also now use the ``__index__()`` method if + available. + (Contributed by Serhiy Storchaka in :issue:`36048` and :issue:`20092`.) * Heap-allocated type objects will now increase their reference count in :c:func:`PyObject_Init` (and its parallel macro ``PyObject_INIT``) |