diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 15:53:19 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 15:53:19 +0200 |
commit | bb6e4a0b31402f2e242f8f4be9a26e07d3dcc1b7 (patch) | |
tree | 552f1bdf983de7b8957bb65597c691c932d063db /Lib/test/test_int.py | |
parent | dde0815c359fc321b0e7a94f885132e2e77534a1 (diff) | |
parent | f9afda57ad7d0394531982b2c9de8301c5a54e45 (diff) | |
download | cpython-git-bb6e4a0b31402f2e242f8f4be9a26e07d3dcc1b7.tar.gz |
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.
Diffstat (limited to 'Lib/test/test_int.py')
-rw-r--r-- | Lib/test/test_int.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py index 3e4b4fc2fd..b66c5d6709 100644 --- a/Lib/test/test_int.py +++ b/Lib/test/test_int.py @@ -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): |