This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author roger.serwy
Recipients kbk, marco, roger.serwy, terry.reedy
Date 2012-01-31.04:54:42
SpamBayes Score 1.209739e-10
Marked as misclassified No
Message-id <1327985683.92.0.539014045852.issue13506@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-01-31 04:54:43roger.serwysetrecipients: + roger.serwy, terry.reedy, kbk, marco
2012-01-31 04:54:43roger.serwysetmessageid: <1327985683.92.0.539014045852.issue13506@psf.upfronthosting.co.za>
2012-01-31 04:54:43roger.serwylinkissue13506 messages
2012-01-31 04:54:42roger.serwycreate