summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-12-17 14:52:45 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-12-17 14:52:45 (GMT)
commit842acaab1376c5c84fd5966bb6070e289880e1ca (patch)
treef21283245b7e349d05482b89fde8d570b33c53ab /Lib/test
parent4db62e115891425db2a974142a72d8eaaf95eecb (diff)
downloadcpython-842acaab1376c5c84fd5966bb6070e289880e1ca.zip
cpython-842acaab1376c5c84fd5966bb6070e289880e1ca.tar.gz
cpython-842acaab1376c5c84fd5966bb6070e289880e1ca.tar.bz2
bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/multibytecodec_support.py5
-rw-r--r--Lib/test/test_asyncio/test_futures.py7
-rw-r--r--Lib/test/test_asyncio/test_tasks.py9
-rw-r--r--Lib/test/test_frame.py10
-rw-r--r--Lib/test/test_io.py5
5 files changed, 32 insertions, 4 deletions
diff --git a/Lib/test/multibytecodec_support.py b/Lib/test/multibytecodec_support.py
index 813b7aa..cca8af6 100644
--- a/Lib/test/multibytecodec_support.py
+++ b/Lib/test/multibytecodec_support.py
@@ -277,6 +277,11 @@ class TestBase:
writer = self.writer(stream)
writer.reset()
+ def test_incrementalencoder_del_segfault(self):
+ e = self.incrementalencoder()
+ with self.assertRaises(AttributeError):
+ del e.errors
+
class TestBase_Mapping(unittest.TestCase):
pass_enctest = []
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py
index 3339356..2e4583d 100644
--- a/Lib/test/test_asyncio/test_futures.py
+++ b/Lib/test/test_asyncio/test_futures.py
@@ -570,6 +570,13 @@ class CFutureTests(BaseFutureTests, test_utils.TestCase):
except AttributeError:
cls = None
+ def test_future_del_segfault(self):
+ fut = self._new_future(loop=self.loop)
+ with self.assertRaises(AttributeError):
+ del fut._asyncio_future_blocking
+ with self.assertRaises(AttributeError):
+ del fut._log_traceback
+
@unittest.skipUnless(hasattr(futures, '_CFuture'),
'requires the C _asyncio module')
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index c65d1f2..22f14f8 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2546,6 +2546,15 @@ class CTask_CFuture_Tests(BaseTaskTests, SetMethodsTest,
self.loop.run_until_complete(task)
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
+ def test_del__log_destroy_pending_segfault(self):
+ @asyncio.coroutine
+ def coro():
+ pass
+ task = self.new_task(self.loop, coro())
+ self.loop.run_until_complete(task)
+ with self.assertRaises(AttributeError):
+ del task._log_destroy_pending
+
@unittest.skipUnless(hasattr(futures, '_CFuture') and
hasattr(tasks, '_CTask'),
diff --git a/Lib/test/test_frame.py b/Lib/test/test_frame.py
index fd79508..d6aa283 100644
--- a/Lib/test/test_frame.py
+++ b/Lib/test/test_frame.py
@@ -109,10 +109,7 @@ class ClearTest(unittest.TestCase):
self.assertIs(None, wr())
-class FrameLocalsTest(unittest.TestCase):
- """
- Tests for the .f_locals attribute.
- """
+class FrameAttrsTest(unittest.TestCase):
def make_frames(self):
def outer():
@@ -159,6 +156,11 @@ class FrameLocalsTest(unittest.TestCase):
self.assertEqual(outer.f_locals, {})
self.assertEqual(inner.f_locals, {})
+ def test_f_lineno_del_segfault(self):
+ f, _, _ = self.make_frames()
+ with self.assertRaises(AttributeError):
+ del f.f_lineno
+
class ReprTest(unittest.TestCase):
"""
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 14352ff..dc353c1 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -3663,6 +3663,11 @@ class CTextIOWrapperTest(TextIOWrapperTest):
t2.buddy = t1
support.gc_collect()
+ def test_del__CHUNK_SIZE_SystemError(self):
+ t = self.TextIOWrapper(self.BytesIO(), encoding='ascii')
+ with self.assertRaises(AttributeError):
+ del t._CHUNK_SIZE
+
class PyTextIOWrapperTest(TextIOWrapperTest):
io = pyio