[3.14] Revert "gh-135410: use a critical section around StringIO.__next__ (GH-135412)" (GH-135439) (gh-135449)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run

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

This reverts commit e6c3039cb3.
(cherry picked from commit 73431356d3)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-06-13 00:58:58 +02:00 committed by GitHub
parent f885c7d9b9
commit b3efd3d7d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 1 additions and 32 deletions

View file

@ -5,7 +5,6 @@ BytesIO -- for bytes
import unittest
from test import support
from test.support import threading_helper
import gc
import io
@ -13,7 +12,6 @@ import _pyio as pyio
import pickle
import sys
import weakref
import threading
class IntLike:
def __init__(self, num):
@ -725,22 +723,6 @@ class TextIOTestMixin:
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 @@ class CStringIOTest(PyStringIOTest):
self.assertRaises(ValueError, memio.__setstate__, ("closed", "", 0, None))
class CStringIOPickleTest(PyStringIOPickleTest):
UnsupportedOperation = io.UnsupportedOperation

View file

@ -1,2 +0,0 @@
Fix a crash when iterating over :class:`io.StringIO` on the :term:`free
threaded <free threading>` build.

View file

@ -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