Hynek confirmed on Big Sur with Python 3.9.5 from asdf that test_input_tty hangs, too, if ran for the second time in the same process.
Moreover, readline is not it. First of all, it's libedit on macOS:
❯ ll /usr/lib/libreadline.dylib
lrwxr-xr-x 1 root wheel 15B Feb 2 2020 /usr/lib/libreadline.dylib -> libedit.3.dylib
So Python uses that by default:
>>> import readline
>>> readline._READLINE_LIBRARY_VERSION
'EditLine wrapper'
>>> readline._READLINE_RUNTIME_VERSION
1026
>>> readline._READLINE_VERSION
1026
Unless you instruct it to use readline (for example by providing "-I$(brew --prefix readline)/include" to CFLAGS and "-L$(brew --prefix readline)/lib" to LDFLAGS before running ./configure):
>>> import readline
>>> readline._READLINE_LIBRARY_VERSION
'8.1'
>>> readline._READLINE_RUNTIME_VERSION
2049
>>> readline._READLINE_VERSION
2049
The hang is the same in both cases.
Next course of action, checking if it's not due to fork shenanigans in _run_child():
https://github.com/python/cpython/blob/1841c70f2bdab9d29c1c74a8afffa45d5555af98/Lib/test/test_builtin.py#L2001 |