summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_int.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-09-27 18:38:59 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-09-27 18:38:59 (GMT)
commit7c95bb35e40a1bb598a259248b5a9880d8716556 (patch)
tree5891ec02508da616ea5bc98e31ac75d9c26663e4 /Lib/test/test_int.py
parent3658cb3012fa14e4594ed62a227115fbbd15da26 (diff)
downloadcpython-7c95bb35e40a1bb598a259248b5a9880d8716556.zip
cpython-7c95bb35e40a1bb598a259248b5a9880d8716556.tar.gz
cpython-7c95bb35e40a1bb598a259248b5a9880d8716556.tar.bz2
Issue #16060: Fix a double DECREF in int() implementation. Thanks Serhiy Storchaka.
Diffstat (limited to 'Lib/test/test_int.py')
-rw-r--r--Lib/test/test_int.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index 437e323..227759f 100644
--- a/Lib/test/test_int.py
+++ b/Lib/test/test_int.py
@@ -305,6 +305,18 @@ class IntTestCases(unittest.TestCase):
self.fail("Failed to raise TypeError with %s" %
((base, trunc_result_base),))
+ # Regression test for bugs.python.org/issue16060.
+ class BadInt(trunc_result_base):
+ def __int__(self):
+ return 42.0
+
+ class TruncReturnsBadInt(base):
+ def __trunc__(self):
+ return BadInt()
+
+ with self.assertRaises(TypeError):
+ int(TruncReturnsBadInt())
+
def test_error_message(self):
testlist = ('\xbd', '123\xbd', ' 123 456 ')
for s in testlist: