Skip to content

gh-102628: Fix sqlite3 CLI promt text on Windows #103898

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

Merged
merged 2 commits into from
Apr 27, 2023

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Apr 26, 2023

CTRL-Z is the Windows equivalent of CTRL-D.
@erlend-aasland
Copy link
Contributor Author

@terryjreedy, will this work on IDLE on Windows, or does that only support CTRL-D?

@terryjreedy
Copy link
Member

First, note that ^Z by itself does not work, which is confusing to *nix users who just learn 'Use ^Z instead of ^D". So maybe it should say "^Z + " or perhaps "^Z in a Windows console". But experienced Windows users 'should' know about -- although I managed to forget occasionally from disuse. What do you think?

Currently, IDLE only supports ^D, which is why I have not done this yet. About a decade ago, someone decided that IDLE should work same across platforms. Because of this issue, I was thinking maybe ^Z should have been left if possible. I don't know if we can make ^D work in CommandPrompt. I suspect not.

The current PR is an improvement, so merge if you want, or with either alternative.

@erlend-aasland
Copy link
Contributor Author

Is there a stable way to detect if we are running in IDLE? I've seen people check if idlelib.run is in sys.modules, but I have no idea if that is too hacky or not.

@erlend-aasland
Copy link
Contributor Author

I landing this, as it is an improvement over the current prompt. I'm slightly reluctant to expanding the prompt as hinted, since I think it is preferable to keep it as succinct as possible.

I still think we should try to fix the IDLE-on-Windows case, though.

@erlend-aasland erlend-aasland merged commit 8def5ef into python:main Apr 27, 2023
@erlend-aasland erlend-aasland deleted the sqlite-cli-fixup branch April 27, 2023 19:23
@erlend-aasland
Copy link
Contributor Author

Thanks for the insight, @terryjreedy. Thanks for the report, @Dutcho

@terryjreedy
Copy link
Member

terryjreedy commented Apr 27, 2023

You merged after I decided to make the 'hack' official and wrote the following. Please do the followup or ask me to.

Good question. At least some people are checking idlelib.run' in sys.modules because I have recommend that probably on python list and certainly on stackoverflow. IDLE starts the user code execution subprocess with `python -c "import('idlelib.run')..." as it is the idlelib module that actually runs user code.

But what about when one starts IDLE with '-n' (no subprocess). This is 'deprecated' and not actively maintained and tested. (However, it has no removal date and I might reverse this.) It happens that other modules currently import common items from run, but these should be moved to util. To avoid breaking what I have suggested, I added a note to my draft issue for populating util that if run imports are removed, 'idlelib.run' must still be added to sys.modules. I should say something in the IDLE doc too.

@erlend-aasland
Copy link
Contributor Author

I merged, since you said:

The current PR is an improvement, so merge if you want, or with either alternative.

Sorry if I misunderstood. Also, I do plan to follow up this; I'll request your review.

If the idlelib.run trick works in most cases, I think we should use that. The deprecated no-subprocess variant you mention seems too much of a corner case to support, in my opinion.

@erlend-aasland
Copy link
Contributor Author

For the record, the follow-up PR is here:

@terryjreedy
Copy link
Member

No misunderstanding. Your question really was a good one. It is one thing to say on SO "Here's a hack that works now" and another to use it in the stdlib. So I reviewed the code to make sure I understood why it works. It turned out that the answer is completely different for the 2 different execution modes. Having it always work is trivial. pyshell already manipulates sys.modules for another back-compatibility issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prompt text in sqlite3 CLI (new in 3.12) is Linux oriented and doesn't apply to Windows
3 participants