From b98c4fbee5ab3f7c1de61c9465b8ab232e0340ce Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 12 Jun 2025 09:34:40 -0400 Subject: [PATCH 1/2] Fix memory leak buildbots. --- Lib/test/test_memoryio.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index 249e0f3ba32f29..0ed2e2a010c800 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -725,22 +725,6 @@ def test_newline_argument(self): for newline in (None, "", "\n", "\r", "\r\n"): self.ioclass(newline=newline) - @unittest.skipUnless(support.Py_GIL_DISABLED, "only meaningful under free-threading") - @threading_helper.requires_working_threading() - def test_concurrent_use(self): - memio = self.ioclass("") - - def use(): - memio.write("x" * 10) - memio.readlines() - - threads = [threading.Thread(target=use) for _ in range(8)] - with threading_helper.catch_threading_exception() as cm: - with threading_helper.start_threads(threads): - pass - - self.assertIsNone(cm.exc_value) - class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, TextIOTestMixin, unittest.TestCase): @@ -907,6 +891,24 @@ def test_setstate(self): memio.close() self.assertRaises(ValueError, memio.__setstate__, ("closed", "", 0, None)) + @unittest.skipUnless(support.Py_GIL_DISABLED, "only meaningful under free-threading") + @threading_helper.requires_working_threading() + def test_concurrent_use(self): + memio = self.ioclass("") + + def use(): + memio.write("x" * 10) + memio.readlines() + + threads = [threading.Thread(target=use) for _ in range(8)] + with threading_helper.catch_threading_exception() as cm: + with threading_helper.start_threads(threads): + pass + + if cm.exc_value is not None: + raise cm.exc_value + + class CStringIOPickleTest(PyStringIOPickleTest): From b6f2011f67c8c791a3dae247da81919b47edfc7c Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Thu, 12 Jun 2025 09:35:36 -0400 Subject: [PATCH 2/2] Remove newlines. --- Lib/test/test_memoryio.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index 0ed2e2a010c800..890c33bc1e3870 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -909,8 +909,6 @@ def use(): raise cm.exc_value - - class CStringIOPickleTest(PyStringIOPickleTest): UnsupportedOperation = io.UnsupportedOperation