[issue22121] Start IDLE from icon in a better place.

2021-03-27 Thread Eryk Sun


Eryk Sun  added the comment:

> if sys.stdout is None and no file in sys.argv

With the app distribution from the Microsoft Store, "idle3.x.exe" is a GUI 
executable that runs idlelib. There isn't a console version. Also, GUI scripts 
are usually run with the pyw.exe launcher or pythonw.exe, e.g. `pyw -m 
idlelib`, to ensure it's not attached to a console session. Otherwise the shell 
waits for a console app such as py.exe, which blocks the console. Moreover, 
when a console session is closed, all processes attached to it have 5 seconds 
to exit before they get terminated. I generally don't want either behavior with 
a GUI app, except for the case of debugging an application that writes debug 
output to standard error or standard output. On the other hand, I generally do 
want to inherit the working directory of the parent process, such as a 
command-line shell. 

I think the problem would be adequately addressed by blacklisting directories 
that are known to be inappropriate and a common problem, such as sys.prefix and 
Windows system directories. I agree with the suggestion to automatically change 
the working directory in such cases to the user's "Documents" directory, i.e. 
FOLDERID_Documents.

--
versions: +Python 3.10 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2021-03-27 Thread Eryk Sun


Eryk Sun  added the comment:

> blacklisting directories 

Ensure that filepaths in sys.argv are resolved before changing out of a 
blacklisted directory. Also, for file open/save dialogs, as opposed to the 
working directory of the Python subprocess (e.g. os.getcwd() in the REPL), it's 
typical to default to the user profile directory or the last-accessed directory 
instead of the process working directory.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2019-07-13 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Steve, there is a problem in both lines of this suggestion.

if os.path.normcase(os.getcwd()) == os.path.normcase(sys.prefix):
os.chdir(get_default_location(sys.platform))

On my 3.8 repository build, 
>>> import os; os.getcwd()
'F:\\dev\\38\\PCbuild\\win32'
>>> import sys; sys.prefix
'F:\\dev\\38'
# Don't match.  The following does.
>>> os.path.dirname(sys.executable)
'F:\\dev\\3x\\PCbuild\\win32'

>>> get_default_location
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'get_default_location' is not defined

Raymond, I understand that you are saying that the current behavior when 
starting from a command prompt is correct (I agree) and depended upon.  I 
changed the title to be clear about that.  Starting IDLE from an icon includes 
starting python from an icon and then starting IDLE with 'import idlelib.idle', 
which I do routinely for repository builds.

--
title: IDLE should start with HOME as the initial working directory -> Start 
IDLE from icon in a better place.
versions: +Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2019-07-13 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
assignee:  -> terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2019-07-13 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Looking at the revised title, +1 for changing the IDLE Icon startup, but let's 
keep the command-line startup sticking with the current directory:

   $ mkdir pyclass
   $ cd pyclass
   $ python3.8 -m idlelib.idle # Should start in the pyclass directory

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2019-07-14 Thread Steve Dower


Steve Dower  added the comment:

> Steve, there is a problem in both lines of this suggestion.

The only problem is that you ran from your own build. Once running from an 
installed layout (which you can now easily generate with `python.bat PC\layout 
--preset-default --copy `), the comparison will be fine.

I think it's fair to assume that the new users we are concerned about are *not* 
building Python from source :)

Otherwise, there's still my suggestion of a command line option to specify the 
start directory - e.g. --start-in-home - that we can put into the shortcut so 
it only affects GUI launches and not command line launches. (Though this idea 
may not be possible with the Store package, as the shortcut is the same for 
both Start and command line.)

Besides those two options, I don't know of another way to make this work. So we 
either need to choose one of them, choose not to fix it, or wait for someone to 
come up with something new.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2019-07-14 Thread Steve Dower


Steve Dower  added the comment:

> NameError: name 'get_default_location' is not defined

Also, this was a hypothetical function that you would implement in IDLE to 
determine whatever the default location ought to be. I'm personally happy to 
stay out of that part of the argument.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2019-07-16 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

An implementation note mostly to myself: In 3.8 and before, 'python 
relative/path/to/file.py' results in the __file__ attribute of the main module 
being the relative path, and a possibly unnormalized full path is os.curdir + 
__file__.  I believe that this is the only situation in which __file__ is not 
absolute.  After os.chdir(new cwd), relative __file__ becomes useless unless 
the original curdir is saved or  __file__ is made absolute first.  The startup 
part of pyshell has this vulnerable line.
icondir = os.path.join(os.path.dirname(__file__), 'Icons')
But with curdir left alone when starting from a command line, there will be no 
problem.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2020-03-10 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

See also #38775 about a configuration option.  The two proposals need to be 
coordinated.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2020-03-12 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

#39927 is about changing the Mac-specific chdir hidden away in
  Mac/IDLE/IDLE.app/Contents/Resources/idlemain.py, line 8
A generic solution should supercede that.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22121] Start IDLE from icon in a better place.

2020-03-12 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

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 = 
try:
chdir(expanduser('~'))
except OSError as e:
 

This might be somehow coordinated with .idlerc location search.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com