mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix segfaults when running test_exceptions with coverage tracing, caused by wrongly defining Exception.__context__ as a T_OBJECT structmember which does not set the member to NULL on None assignment, and generally does not do type checks. This could be used to crash the interpreter by setting any object to __context__. The same applies to __cause__. Also document the PyException_* functions.
This commit is contained in:
parent
71095ea4ce
commit
ab6f2f6eb6
4 changed files with 114 additions and 10 deletions
|
@ -341,6 +341,12 @@ class ExceptionTests(unittest.TestCase):
|
|||
else:
|
||||
self.fail("No exception raised")
|
||||
|
||||
def testInvalidAttrs(self):
|
||||
self.assertRaises(TypeError, setattr, Exception(), '__cause__', 1)
|
||||
self.assertRaises(TypeError, delattr, Exception(), '__cause__')
|
||||
self.assertRaises(TypeError, setattr, Exception(), '__context__', 1)
|
||||
self.assertRaises(TypeError, delattr, Exception(), '__context__')
|
||||
|
||||
def testNoneClearsTracebackAttr(self):
|
||||
try:
|
||||
raise IndexError(4)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue