summaryrefslogtreecommitdiff
path: root/Lib/test/test_int.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-09-27 19:38:59 +0100
committerMark Dickinson <mdickinson@enthought.com>2012-09-27 19:38:59 +0100
commitc19f677fb7350924e56970c294dcdb292b2fefac (patch)
tree52aa13a2ca2ff1eb12ef7bf821c60ffc501cdc1b /Lib/test/test_int.py
parent9f1ce8e27383fbe10e6efedbf0b657a0cfca30b4 (diff)
downloadcpython-c19f677fb7350924e56970c294dcdb292b2fefac.tar.gz
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 437e323cbc..227759f269 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: