Skip to content
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

Fix non-interactive with param -i in subprocess #2557

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

a690700752
Copy link

continue #2555 .
When I use the -i parameter to force the launch of the REPL and send code in subprocess (using nvim conjure), it directly enters the repl.runsource block for execution and never enters repl.run(). In this case, the current environment is not the REPL environment, lacking the PS1, PS2 prompts, and some other REPL-specific environment settings, which contradicts the meaning of the -i parameter. On the other hand, other branches execute code first, such as from a file, before entering repl.run().

@Kodiologist Kodiologist mentioned this pull request Mar 10, 2024
@Kodiologist
Copy link
Member

When making further changes to this PR, please add commits (or force-push) rather than closing it and making a new one.

@Kodiologist
Copy link
Member

The test is a bit wonky. Giving the default argument to getattr means that you're accepting either of sys.ps1 or sys.flags.interactive. Shouldn't you be more specific as to which you expect, or simply test for both?

@a690700752
Copy link
Author

There just a tests result, below is the result. Maybe we can add comment to that test code.

Environment IPython PyCharm Console Shell (run Python, paste code) Jupyter Notebook PyCharm Run PyCharm Run (Emulate terminal) Shell (run Python file)
Expected Value TRUE TRUE TRUE TRUE FALSE FALSE FALSE
hasattr(sys,'ps1') TRUE TRUE TRUE TRUE FALSE FALSE FALSE
hasattr(sys,'ps2') TRUE TRUE TRUE TRUE FALSE FALSE FALSE
sys.__stdin__.isatty() TRUE FALSE TRUE FALSE FALSE TRUE TRUE
sys.__stdout__.isatty() TRUE FALSE TRUE TRUE FALSE TRUE TRUE
hasattr(__builtins__,'__IPYTHON__') TRUE FALSE FALSE TRUE FALSE FALSE FALSE
not hasattr(__main**, '__file__') TRUE FALSE TRUE TRUE FALSE FALSE TRUE
bool(sys.flags.interactive) FALSE FALSE FALSE FALSE FALSE FALSE FALSE

@Kodiologist
Copy link
Member

That's an impressive table you've compiled, but your test only checks hy -i, so that's what the assertion should be written for.

@a690700752
Copy link
Author

Ok, I'll continue finish tests.

@Kodiologist
Copy link
Member

How's this going?

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.

None yet

2 participants