[issue25488] IDLE: Remove idlelib from sys.path when added

Terry J. Reedy report at bugs.python.org
Tue Oct 27 07:18:51 EDT 2015


Terry J. Reedy added the comment:

When python is started without running a file (Windows icon or command line), '' is prepended to sys.path.  When IDLE is started from 3.5 icon, '' is prepended temporally after and spatially before '.../idlelib', so the latter, to be removed, is sys.path[1] and not sys.path[0].

'' in sys.path interpreted as the current working directory.

When IDLE is started from the command line with '-m idlelib' instead of '.../idlelib/idle.py' (for instance), the current working directory is added instead of .../idlelib (in second position).

Adding the startup current directory is redundant with '' until the user imports os and changes the cwd.  Then I expect the behavior of Shell to be different from python interactive mode, which would be a bug.  I will try to find a test case later.
  
PyShell.main manipulates 'sys.path' in lines 1521 and 1525, but these are sys.argv of the idle process, not the user process, each of which have their own sys.argv. If filenames are given on the command line to be edited, the directory of each is added to sys.path *for the idle process* (line 1521).  I suspect this is for completions. Line 1525 add the current working directory.  I don't know why.  Perhaps it is a holdover for -n single process mode.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25488>
_______________________________________


More information about the Python-bugs-list mailing list