-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-48752: Add readline.get_pre_input_hook() function #141586
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
gh-48752: Add readline.get_pre_input_hook() function #141586
Conversation
a2e250f to
e73c48f
Compare
Lib/test/test_readline.py
Outdated
| get_pre_input_hook = getattr(readline, "get_pre_input_hook", None) | ||
| if get_pre_input_hook is None: |
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.
I would prefer to check for hasattr() here, and use readline.get_pre_input_hook() in the code below.
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.
Hi @vstinner 👋🏼
I have addressed your review. Would you mind taking another pass at this, please?
e73c48f to
9fe75be
Compare
Lib/test/test_readline.py
Outdated
|
|
||
| # Clear the hook and verify it returns None again | ||
| readline.set_pre_input_hook(None) | ||
| self.assertIsNone(readline.get_pre_input_hook()) |
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.
I don't see the point of checking None twice.
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.
Done, removed the redundant check. Thanks for the review!
Doc/library/readline.rst
Outdated
| function has been set. This function only exists if Python was compiled | ||
| for a version of the library that supports it. | ||
|
|
||
| .. versionadded:: 3.15 |
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.
| .. versionadded:: 3.15 | |
| .. versionadded:: next |
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, #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
|
Merged. Thanks for your contribution! |
…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.
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.