-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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-121245: Refactor site.register_readline() #121659
gh-121245: Refactor site.register_readline() #121659
Conversation
also initialize CAN_USE_PYREPL at import from _pyrepl.main
@smontanaro, if you can reproduce #121245, then please try this patch. |
I can't reproduce #121245:
```
% cat ~/.python_history
'Save this'
'Save this'
```
…On Fri, Jul 12, 2024 at 10:52 PM Sergey B Kirpichev < ***@***.***> wrote:
@smontanaro <https://github.com/smontanaro>, if you can reproduce #121245
<#121245>, then please try this
patch.
—
Reply to this email directly, view it on GitHub
<#121659 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2E3IMUEY3VAZEH2VFUTZLZMCQAFAVCNFSM6AAAAABKZ4WHXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRWG42TIOJWHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
That said, I agree now my idea for skipping the test is wrong. Rebuilding the |
Then I would guess, as noted in #121422, that problem is related to your local customization. Try unset all PYTHON* environment variables and run tests. |
I get that, and yes, I agree, my personal interactive settings are interfering. I have long had readline customizations in my setup. I think the correct solution is for the test suite to be run in isolation, at least that part of it which purports to test interactive features such as readline. See Victor's fix in #121414. |
Unfortunately, this fix already applied and it's not enough. We can do a local fix: diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py
index 015b690566..88b1dc38f0 100644
--- a/Lib/test/test_pyrepl/test_pyrepl.py
+++ b/Lib/test/test_pyrepl/test_pyrepl.py
@@ -909,6 +909,12 @@ def test_not_wiping_history_file(self):
hfile = tempfile.NamedTemporaryFile(delete=False)
self.addCleanup(unlink, hfile.name)
env = os.environ.copy()
+
+ # cleanup from PYTHON* variables
+ for k in env.copy():
+ if k.startswith("PYTHON"):
+ env.pop(k)
+
env["PYTHON_HISTORY"] = hfile.name
commands = "123\nspam\nexit()\n"
Let me know if this does work for you. But I'm thinking on a more generic solution: probably we should instead make a default environment for all tests (say, my_env), clean PYTHON* variables in one and then in every test do my_env.copy(). Edit: typo fixed, sorry :( |
See #121672 |
|
Lib/site.py
Outdated
readline.read_history_file(history) | ||
else: | ||
_pyrepl.readline.read_history_file(history) | ||
my_readline.read_history_file(history) |
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.
my_readline.read_history_file(history) | |
target_readline.read_history_file(history) |
Thanks for the PR @skirpichev. Unfortunately you are mixing what seems to be a fix for #121245 with a general refactor, what makes more difficult to understand what is happening here and what is and what isn't necessary. What is worse, it makes it not possible to back port because 3.13 accepts bug fixes but in no way refactors. Can you please keep the changes to only the minimum set of things require to fix #121245? |
@pablogsal, in fact I think that that issue is fixed (but I'm not sure, heh). It was reopened by my request, because added regression has many failures on build bots. But this seems to be fixed by #121422. I still think, that refactoring belongs to the #121245. With new code it's obvious that we are using same readline both while reading the history and while writing... Does this make sense for you? |
|
||
|
||
def interactive_console(mainmodule=None, quiet=False, pythonstartup=False): | ||
global CAN_USE_PYREPL | ||
if not CAN_USE_PYREPL: |
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.
This old case only happened for old Windows, in which case we didn't print any warning. This is now changing but I think that's fine.
Thanks @skirpichev for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
(cherry picked from commit 05d4137) Co-authored-by: Sergey B Kirpichev <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
GH-121816 is a backport of this pull request to the 3.13 branch. |
…21816) (cherry picked from commit 05d4137) Co-authored-by: Sergey B Kirpichev <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
Co-authored-by: Łukasz Langa <[email protected]>
also initialize CAN_USE_PYREPL at import from _pyrepl.main