summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_int.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-25 13:47:01 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-25 13:47:01 (GMT)
commit15095800a381a396cbc077cb5320203a8feae51a (patch)
treeba1f16c1b9be09a1f14d3af644c39e52924ee63f /Lib/test/test_int.py
parenta49de6be3669e4698ea55d22e0fdebb29be63f2e (diff)
downloadcpython-15095800a381a396cbc077cb5320203a8feae51a.zip
cpython-15095800a381a396cbc077cb5320203a8feae51a.tar.gz
cpython-15095800a381a396cbc077cb5320203a8feae51a.tar.bz2
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.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index ab3917f..4906e46 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):