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 terry.reedy
Recipients andyharrington, eryksun, jeff.allen, mark, ned.deily, rhettinger, serhiy.storchaka, steve.dower, terry.reedy
Date 2020-03-13.03:08:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584068901.48.0.374517887761.issue22121@roundup.psfhosted.org>
In-reply-to
Content
Recap and proposal

When editing a named file, Open and Save start in the directory of that file.  Running a file sets the initial working directory of the execution process, which affects imports in the code.

We are here discussing the working directory for the IDLE process.  This affects a. the working directory for interactive code entered without having first run from the editor; b. the start directory for Open and Save in both Shell and any untitled editor windows.

When IDLE is started with command line 'python -m idlelib', its working directory is that of the console.  We agree that IDLE should not change this.  In this case, sys.stdout is not None.  (The exception is when one starts with pythonw, which which is normally useless in the console.)

When IDLE is started Windows Explorer by right clicking a file and selecting 'Edit with IDLE' its working directory is the same as the file.  I propose that IDLE should not change the directory in this case either. In this case, there is at least one filename in sys.args, which IDLE parses anyway.

I initially considered this issue to be about changing the installed Start menu shortcut.  But it was suggested that IDLE code might be better.  Adding a configuration option would require this.  Such code would also not be limited to Windows.  I am currently thinking of something like

if sys.stdout is None and no file in sys.argv:
    start_dir = idleConf(...) #28775, default None?.
    if start_dir is None:
        start_dir = <system-specific default
    try:
        chdir(start_dir)
    except OSError as e:
        <display message>
        try:
            chdir(expanduser('~'))
        except OSError as e:
             <display message -- stay with system default>

This might be somehow coordinated with .idlerc location search.
History
Date User Action Args
2020-03-13 03:08:21terry.reedysetrecipients: + terry.reedy, rhettinger, andyharrington, mark, ned.deily, serhiy.storchaka, jeff.allen, eryksun, steve.dower
2020-03-13 03:08:21terry.reedysetmessageid: <1584068901.48.0.374517887761.issue22121@roundup.psfhosted.org>
2020-03-13 03:08:21terry.reedylinkissue22121 messages
2020-03-13 03:08:20terry.reedycreate