Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Lib/test/test_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import sys
import tempfile
import textwrap
import threading
import unittest
from test import support
from test.support import threading_helper
from test.support import verbose
from test.support.import_helper import import_module
from test.support.os_helper import unlink, temp_dir, TESTFN
Expand Down Expand Up @@ -403,5 +406,49 @@ def test_write_read_limited_history(self):
# See TestHistoryManipulation for the full test.


@unittest.skipUnless(support.Py_GIL_DISABLED, 'these tests can only possibly fail with GIL disabled')
class FreeThreadingTest(unittest.TestCase):
def check(self, funcs, *args):
barrier = threading.Barrier(len(funcs))
threads = []

for func in funcs:
thread = threading.Thread(target=func, args=(barrier, *args))

threads.append(thread)

with threading_helper.start_threads(threads):
pass

@threading_helper.reap_threads
@threading_helper.requires_working_threading()
def test_free_threading(self):
def completer_delims(b):
b.wait()
for _ in range(100):
readline.get_completer_delims()
readline.set_completer_delims(' \t\n`@#%^&*()=+[{]}\\|;:\'",<>?')
readline.set_completer_delims(' \t\n`@#%^&*()=+[{]}\\|;:\'",<>?')
readline.get_completer_delims()

self.check([completer_delims] * 100)

def test_free_threading_doctest_difflib(self):
code = textwrap.dedent("""
from threading import Thread
import doctest, difflib

def _test():
try:
doctest.testmod(difflib)
except RecursionError:
pass

for x in range(40):
Thread(target=_test, args=()).start()
""")
assert_python_ok("-c", code)


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`readline` in :term:`free-threaded <free threading>` build.
115 changes: 109 additions & 6 deletions Modules/clinic/readline.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading