bpo-36048: Use __index__() instead of __int__() for implicit conversion if available. by serhiy-storchaka · Pull Request #11952 · python/cpython
…on if available. Deprecate using the __int__() method in implicit conversions of Python numbers to C integers.
tacaswell added a commit to tacaswell/matplotlib that referenced this pull request
Sep 1, 2019This is a workaround to https://bugs.python.org/issue37980 - np.bool raises a warning if you try to use it as an index (by warning in its `__index__` method - in py38 python/cpython#11952 python changes the code path used to convert `np.bool_` -> int for as it is used in `sorted` so it now goes through the `__index__` code path - this causes a bunch of spurious warnings to come out of Matplotlib.
tacaswell added a commit to tacaswell/matplotlib that referenced this pull request
Sep 2, 2019This is a workaround to https://bugs.python.org/issue37980 - np.bool raises a warning if you try to use it as an index (by warning in its `__index__` method - in py38 python/cpython#11952 python changes the code path used to convert `np.bool_` -> int for as it is used in `sorted` so it now goes through the `__index__` code path - this causes a bunch of spurious warnings to come out of Matplotlib.
tacaswell added a commit to tacaswell/matplotlib that referenced this pull request
Sep 4, 2019This is a workaround to https://bugs.python.org/issue37980 - np.bool raises a warning if you try to use it as an index (by warning in its `__index__` method - in py38 python/cpython#11952 python changes the code path used to convert `np.bool_` -> int for as it is used in `sorted` so it now goes through the `__index__` code path - this causes a bunch of spurious warnings to come out of Matplotlib.
chrisnovakovic added a commit to chrisnovakovic/cpython that referenced this pull request
Mar 17, 2023…ted as integers Prior to pythongh-11952, several standard library functions that expected integer arguments would nevertheless silently accept (and truncate) non-integer arguments. This behaviour was deprecated in pythongh-11952, and removed in pythongh-15636. However, it may be possible to interpret some non-integer numeric types (such as `decimal.Decimal`s) as integers if they contain no fractional part. Implement `__index__` for `decimal.Decimal`, returning an integer representation of the value if it does not contain a fractional part or raising a `TypeError` if it does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters