gh-48752: Add readline.get_pre_input_hook() function#141586
Merged
vstinner merged 1 commit intoDec 5, 2025
Merged
Conversation
a2e250f to
e73c48f
Compare
vstinner
reviewed
Nov 17, 2025
Comment on lines
+420
to
+421
| get_pre_input_hook = getattr(readline, "get_pre_input_hook", None) | ||
| if get_pre_input_hook is None: |
Member
There was a problem hiding this comment.
I would prefer to check for hasattr() here, and use readline.get_pre_input_hook() in the code below.
Member
Author
There was a problem hiding this comment.
Hi @vstinner 👋🏼
I have addressed your review. Would you mind taking another pass at this, please?
e73c48f to
9fe75be
Compare
vstinner
reviewed
Dec 1, 2025
|
|
||
| # Clear the hook and verify it returns None again | ||
| readline.set_pre_input_hook(None) | ||
| self.assertIsNone(readline.get_pre_input_hook()) |
Member
There was a problem hiding this comment.
I don't see the point of checking None twice.
Member
Author
There was a problem hiding this comment.
Done, removed the redundant check. Thanks for the review!
| function has been set. This function only exists if Python was compiled | ||
| for a version of the library that supports it. | ||
|
|
||
| .. versionadded:: 3.15 |
Member
There was a problem hiding this comment.
Suggested change
| .. versionadded:: 3.15 | |
| .. versionadded:: next |
Member
Author
There was a problem hiding this comment.
Thanks, #TIL about the next version.
9fe75be to
c89e904
Compare
Add readline.get_pre_input_hook() to retrieve the current pre-input hook. This allows applications to save and restore the hook without overwriting user settings.
c89e904 to
a4de2bd
Compare
Member
|
Merged. Thanks for your contribution! |
StanFromIreland
pushed a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
…1586) Add readline.get_pre_input_hook() to retrieve the current pre-input hook. This allows applications to save and restore the hook without overwriting user settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #48752
Add
readline.get_pre_input_hook()to retrieve the current pre-input hook. This allows applications to save and restore the hook without overwriting user settings.