https://github.com/python/cpython/commit/73431356d324842cac0d545018c3ad21c85bc883
commit: 73431356d324842cac0d545018c3ad21c85bc883
branch: main
author: Peter Bierma <zintensity...@gmail.com>
committer: corona10 <donghee.n...@gmail.com>
date: 2025-06-13T07:32:27+09:00
summary:

Revert "gh-135410: use a critical section around `StringIO.__next__` (#135412)" 
(#135439)

This reverts commit e6c3039cb39e68ae9af9ddcaca341c5af8f9cf23.

files:
D Misc/NEWS.d/next/Library/2025-06-11-19-05-49.gh-issue-135410.E89Boi.rst
M Lib/test/test_memoryio.py
M Modules/_io/stringio.c

diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index 249e0f3ba32f29..63998a86c45b53 100644
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -5,7 +5,6 @@
 
 import unittest
 from test import support
-from test.support import threading_helper
 
 import gc
 import io
@@ -13,7 +12,6 @@
 import pickle
 import sys
 import weakref
-import threading
 
 class IntLike:
     def __init__(self, num):
@@ -725,22 +723,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):
@@ -908,7 +890,6 @@ def test_setstate(self):
         self.assertRaises(ValueError, memio.__setstate__, ("closed", "", 0, 
None))
 
 
-
 class CStringIOPickleTest(PyStringIOPickleTest):
     UnsupportedOperation = io.UnsupportedOperation
 
diff --git 
a/Misc/NEWS.d/next/Library/2025-06-11-19-05-49.gh-issue-135410.E89Boi.rst 
b/Misc/NEWS.d/next/Library/2025-06-11-19-05-49.gh-issue-135410.E89Boi.rst
deleted file mode 100644
index a5917fba3f7bb9..00000000000000
--- a/Misc/NEWS.d/next/Library/2025-06-11-19-05-49.gh-issue-135410.E89Boi.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Fix a crash when iterating over :class:`io.StringIO` on the :term:`free
-threaded <free threading>` build.
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c
index 8482c268176c5b..56913fafefba8b 100644
--- a/Modules/_io/stringio.c
+++ b/Modules/_io/stringio.c
@@ -404,7 +404,7 @@ _io_StringIO_readline_impl(stringio *self, Py_ssize_t size)
 }
 
 static PyObject *
-stringio_iternext_lock_held(PyObject *op)
+stringio_iternext(PyObject *op)
 {
     PyObject *line;
     stringio *self = stringio_CAST(op);
@@ -441,16 +441,6 @@ stringio_iternext_lock_held(PyObject *op)
     return line;
 }
 
-static PyObject *
-stringio_iternext(PyObject *op)
-{
-    PyObject *res;
-    Py_BEGIN_CRITICAL_SECTION(op);
-    res = stringio_iternext_lock_held(op);
-    Py_END_CRITICAL_SECTION();
-    return res;
-}
-
 /*[clinic input]
 @critical_section
 _io.StringIO.truncate

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to