Roger Serwy <roger.se...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13506>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to