Skip to content

gh-126895: fix readline module in free-threaded build #131208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 24 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,26 @@ 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):
@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()

count = 40
barrier = threading.Barrier(count)
threads = [threading.Thread(target=completer_delims, args=(barrier,)) for _ in range(count)]

with threading_helper.start_threads(threads):
pass


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.
125 changes: 119 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