mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-36048: Use __index__() instead of __int__() for implicit conversion if available. (GH-11952)
Deprecate using the __int__() method in implicit conversions of Python numbers to C integers.
This commit is contained in:
parent
d90a141bb9
commit
6a44f6eef3
18 changed files with 326 additions and 55 deletions
|
@ -385,7 +385,8 @@ class IntTestCases(unittest.TestCase):
|
|||
class TruncReturnsNonInt(base):
|
||||
def __trunc__(self):
|
||||
return Integral()
|
||||
self.assertEqual(int(TruncReturnsNonInt()), 42)
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
self.assertEqual(int(TruncReturnsNonInt()), 42)
|
||||
|
||||
class NonIntegral(trunc_result_base):
|
||||
def __trunc__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue