Message152369
I tested your patch and it works. For the sake of completeness, here's what I did:
Test 1: Start IDLE in shell mode and run "import sys; print(sys.path)". The first entry should be ''
This is consistent with the behavior of the regular python shell.
Test 2: Restart the shell with Ctrl+F6 (and View->Restart Shell) and repeat Test 1. This should give the same result.
Test 3: Create a script in /tmp/a.py with "import sys; print(sys.path)" as its contents. Running this script from the editor gives '/tmp' as the first entry.
This is consistent with the behavior of running "python3 /tmp/a.py".
I'd make one minor change to the patch for sake of being explicit in ScriptBinding.py:
shell.restart_shell(event, with_cwd=False)
My rationale was to modify only PyShell.py to get the correct behavior. Clearly, making a simple modification to ScriptBinding.py gives a much shorter solution. I also like your simplification for "start_subprocess".
I did consider each case of default arguments. I developed my patch iteratively starting by having "with_cwd=False" for all function calls that called "transfer_path" so that the existing (incorrect) behavior remained. I then modified how these functions were called, setting "with_cwd=True" in the cases where '' needed to be transferred, namely on the shell start and restart from within the PyShell window. That is why I introduced "restart_shell_interactive". I do agree with your reasoning that one function call is better than two. |
|
Date |
User |
Action |
Args |
2012-01-31 04:54:43 | roger.serwy | set | recipients:
+ roger.serwy, terry.reedy, kbk, marco |
2012-01-31 04:54:43 | roger.serwy | set | messageid: <1327985683.92.0.539014045852.issue13506@psf.upfronthosting.co.za> |
2012-01-31 04:54:43 | roger.serwy | link | issue13506 messages |
2012-01-31 04:54:42 | roger.serwy | create | |
|