summaryrefslogtreecommitdiff
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2013-03-03 11:13:34 +0000
committerMark Dickinson <dickinsm@gmail.com>2013-03-03 11:13:34 +0000
commit7cac1c25a144a5d17353a245cec39198dc0b5d21 (patch)
tree5204fb335f7d1a849438e3e87b1eeaeb469f0a4b /Lib/test/test_exceptions.py
parentff0deb0529e4d1419f020ef1939180fae7ed0a4f (diff)
downloadcpython-git-7cac1c25a144a5d17353a245cec39198dc0b5d21.tar.gz
Issue #16445: Fix potential segmentation fault when deleting an exception message.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 216064161c..a485cba893 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -479,6 +479,18 @@ class ExceptionTests(unittest.TestCase):
except AssertionError as e:
self.assertEqual(str(e), "(3,)")
+ def test_bad_exception_clearing(self):
+ # See issue 16445: use of Py_XDECREF instead of Py_CLEAR in
+ # BaseException_set_message gave a possible way to segfault the
+ # interpreter.
+ class Nasty(str):
+ def __del__(message):
+ del e.message
+
+ e = ValueError(Nasty("msg"))
+ e.args = ()
+ del e.message
+
# Helper class used by TestSameStrAndUnicodeMsg
class ExcWithOverriddenStr(Exception):