Terry J. Reedy added the comment:

>I think the next interesting question is to find out why an invalid home 
>directory causes idle to not start up.  There's no obvious reason why that 
>should be the case in principle,

As Roger showed, IDLE will start up with an invalid home directory.

> so I suspect there's some error handling missing somewhere

Yes, the uncaught exception raised when attempting to display a non-essential 
but user-useful messages (this is the third issue I know of about this). There 
are 5 places in configHandler.py where a warning is directly printed to 
sys.stderr. There are two similar writes in PyShell.py. The first warning is 
the problem here, but any of them could be a problem and all should be handled 
better.

Lib/idlelib\PyShell.py: 1357: sys.stderr.write("Error: %s\n" % str(msg))
Lib/idlelib\PyShell.py: 1358: sys.stderr.write(usage_msg)
Lib/idlelib\configHandler.py: 209:    sys.stderr.write(warn)
Lib/idlelib\configHandler.py: 223:    sys.stderr.write(warn)
Lib/idlelib\configHandler.py: 255:    sys.stderr.write(warning)
Lib/idlelib\configHandler.py: 367:    sys.stderr.write(warning)
Lib/idlelib\configHandler.py: 624:    sys.stderr.write(warning)

Why are warning used instead of message boxes? Perhaps easier, perhaps the 
latter are not available because the tk loop is not running. Possible solutions:

* Discard the message by just catching AttributeError (clikkeb) -- at each 
place indicated above. This would be better than nothing, but only as a 
temporary measure, and there is a better temporary measure below.

* Rearrange the start up process to make message boxes available, with default 
configuraton, before the configuration process.

* Make a list of messages and display them when it must (on exit, if that is 
possible with atexit) or in message boxes when it can.

* Solve the more general problem of writing to None by making sys.stdout and 
sys.stderr not be None, #13582. At minimum, even as a temporary measure, use 
something that just swallows output. Something like

import io
class DummyOut(io.IOBase):
    def write(self, s):
        return len(s)

dum = DummyOut()
print(dum.write('sixsix'))
# 6

----------
title: IDLE cannot connect to subprocess - New solution -> IDLE: closes when 
writing warnings on Windows

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

Reply via email to