mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
Issue #24731: Fixed crash on converting objects with special methods
__bytes__, __trunc__, and __float__ returning instances of subclasses of bytes, int, and float to subclasses of bytes, int, and float correspondingly.
This commit is contained in:
parent
a49de6be36
commit
15095800a3
8 changed files with 50 additions and 10 deletions
|
@ -24,6 +24,9 @@ L = [
|
|||
("\u0200", ValueError)
|
||||
]
|
||||
|
||||
class IntSubclass(int):
|
||||
pass
|
||||
|
||||
class IntTestCases(unittest.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
|
@ -441,6 +444,10 @@ class IntTestCases(unittest.TestCase):
|
|||
good_int = TruncReturnsIntSubclass()
|
||||
n = int(good_int)
|
||||
self.assertEqual(n, 1)
|
||||
self.assertIs(type(n), bool)
|
||||
n = IntSubclass(good_int)
|
||||
self.assertEqual(n, 1)
|
||||
self.assertIs(type(n), IntSubclass)
|
||||
|
||||
def test_error_message(self):
|
||||
def check(s, base=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue