-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-116402: Avoid readline in test_builtin TTY input tests #122447
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
Conversation
|
@Eclips4, can you confirm this fixes the issue for you? |
Yes! Thanks for the fix! |
JelleZijlstra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this also fixes test_builtin for me locally.
|
All buildbots (including refleaks and bigmem) passed save for "iOS ARM64 Simulator" with an unrelated failure. Rebasing on main with the |
|
Thanks @ambv for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…onGH-122447) (cherry picked from commit 1d8e453) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
GH-122472 is a backport of this pull request to the 3.13 branch. |
Summary: upstream issue: python/cpython#116402 upstream PR: python/cpython#122447 `test_builtin.test_input_tty` is consistently hanging on macOS when running the full test suite in a single worker, due to an issue with `readline` being imported earlier in the same process. this upstream patch fixes that by temporarily "detaching" readline. here's the upstream PR description: The intention here is to make the TTY `input()` tests run in as many scenarios as possible. For this to happen, we need to temporarily remove the function pointer set to `call_readline` in `PyInit_readline()`. This pointer is normally `NULL` without `readline` and `PyOS_Readline` uses a basic implementation of its own in this case. This is what we want. We could try and avoid importing `readline` in tests, but we have played this whack-a-mole for a long time. For instance, now that `pdb` uses `rlcompleter`, `test_builtin` imports that always (since it imports `doctest` in `load_tests()` and `doctest` imports `pdb` as it subclasses it). I think we should stop trying to not load `readline`, and just detach its function temporarily. This avoids discussions of "unimporting" readline, which would be problematic as `PyInit_readline()` sets global state on the C side through `setup_readline`. While CI is famously not run with a TTY and those tests will be skipped there, people running tests sequentially from their terminal will now be able to have those tests run in many more situations than before. I did the function pointer unsetting with `ctypes` for simplicity. If that's unavailable, the context manager simply skips the tests. Reviewed By: bowiechen Differential Revision: D77306493 fbshipit-source-id: fd9816286865ffd9cdbc3ceb7371402df23a2725
The intention here is to make the TTY
input()tests run in as many scenarios as possible. For this to happen, we need to temporarily remove the function pointer set tocall_readlineinPyInit_readline(). This pointer is normallyNULLwithoutreadlineandPyOS_Readlineuses a basic implementation of its own in this case. This is what we want.We could try and avoid importing
readlinein tests, but we have played this whack-a-mole for a long time. For instance, now thatpdbusesrlcompleter,test_builtinimports that always (since it importsdoctestinload_tests()anddoctestimportspdbas it subclasses it). I think we should stop trying to not loadreadline, and just detach its function temporarily. This avoids discussions of "unimporting" readline, which would be problematic asPyInit_readline()sets global state on the C side throughsetup_readline.While CI is famously not run with a TTY and those tests will be skipped there, people running tests sequentially from their terminal will now be able to have those tests run in many more situations than before.
I did the function pointer unsetting with
ctypesfor simplicity. If that's unavailable, the context manager simply skips the tests.test_builtin.PtyTests.test_input_ttyhangs ifrlcompleteris imported #116402