Michael Foord | 3 Dec 2004 18:56

IDLE Development and Suggestions

Is their still progress on the development of IDLE ? (This group is very 
quiet !).

I generally find IDLE a very nice editor. It has a few minor flaws that 
make it a bit more annoying to use than it should be though :

    Under windows subprocess crashes IDLE if it has more than one 
interactive shell open - editing modules without a subprocess is very 
frustrating !

    A lack of horizontal scrollbar

    No cut and past in the context menu (selected text disappears when 
you right click because you've forgotten IDLE doesn't have cut and paste 
like everything else - doh !)

    In windows it is normal to leave the contents of the clipboard when 
closing an application. Loads of times I've opened IDLE, copied some 
code I need and closed IDLE again. Gone to paste it into another 
application *damn* it's vanished from the clipboard....

I've also been having fun trying to bundle IDLE using py2exe. I'll send 
a separate email about that.

Best Regards,

Michael Foord
http://www.voidspace.org.uk/atlantibots/pythonutils.html
Michael Foord | 3 Dec 2004 19:07

Bundling IDLE with py2exe

I'm attempting to bundle IDLE with py2exe (at one of my jobs I don't 
have admin rights.. so can't install anything - but I can run stuff that 
doesn't need installing).

I've overcome the first couple of problems (py2exe files don't have a 
__file__ attribute, IDLE uses __import__ so I need to manually add some 
modules etc).

However - what I have got so far doesn't work, unsurprisingly. What it 
does do is rather surprising and I'd appreciate a bit of help knowing 
where to look.

When I launch my current idle.exe it launches literally hundreds of 
subprocesses. I then have to reboot !

Any clues as to where in the code this would be happening from ?

Regards,

Fuzzy
http://www.voidspace.org.uk/atlantibots/pythonutils.html
cyber_rebate | 16 Dec 2004 09:10
Picon

coloring letters in output idle window

Hello,


Is there a way to specify the text color using Python 2.3.4 or Idle 1.0.3  ?

I’m using python 2.3.4 with idle 1.0.3 to write some encryption programs and want to print the plaintext in one color and the ciphertext in a different color.

Also it would be nice when using regular expressions to color matches a different color than the text that doesn’t match.  Can different colors be sent to the Idle output window?

 

Thanks,

Dillweed

_______________________________________________
IDLE-dev mailing list
IDLE-dev <at> python.org
http://mail.python.org/mailman/listinfo/idle-dev
Guido van Rossum | 16 Dec 2004 17:32
Picon
Gravatar

Re: coloring letters in output idle window

>  Is there a way to specify the text color using Python 2.3.4 or Idle 1.0.3 
> ? 
> 
> I'm using python 2.3.4 with idle 1.0.3 to write some encryption programs and
> want to print the plaintext in one color and the ciphertext in a different
> color. 

Python itself doesn't have this option. In IDLE,  a hack would be to
switch between writing to sys.stdout and sys.stderr -- these are
displayed in different colors. But this only works in IDLE, and your
program would print everything in the same boring color on all other
platforms (plus, the interspersing of stdout and stderr depends on the
buffering options for both files unless you use flush() a lot).

> Also it would be nice when using regular expressions to color matches a
> different color than the text that doesn't match.  Can different colors be
> sent to the Idle output window? 

In general, when you find this need, you should consider building a
real GUI using Tkinter (the same toolkit used to create IDLE) or
wxPython, but those have serious learning curves. I find Fredrik
Lundh's tutorials and examples on effbot.org very helpful; there's
also a book, Python and Tkinter Programming by John E. Grayson, which
you may find second-hand on the web.

If you're on Unix (including Linux), the curses module will let you do
this; it also has a bit of a learning curve but not quite as much as
the typical GUI toolkit.

Most terminal emulators (but not IDLE) also support using escape
sequences for specifying colors (this is how curses works). Googling
for ANSI escapes should get you the basic idea (ESC is "\033" in
Python). This should work on Windows in CMD windows and on Unix in
most terminal programs (e.g. xterm). I think support in remote
terminal programs (e.g. putty on Windows) is spotty; you might end up
with only being able to choose between regular and bold.

Good luck!

--

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
John Zelle | 16 Dec 2004 18:25

Leaving subprocesses hanging

Hello all,

I'm new to the idle-dev list, but felt I needed to post here for some 
assistance. I am in communication with a number of college faculty using 
Python to teach introductory programming courses. There has been growing 
frustration that newer versions of IDLE seem to be less stable. In 
particular, especially under Windows XP, there are times when IDLE 
becomes unresponsive (hangs). This seems to be related to losing proper 
communication with its subprocess. The only way to get things cleaned up 
again is to go into the process manager and kill the stray pythonw 
processes. Unfortunately, the behavior is sporadic and hard to pin down.

I did a little poking around in the idle-dev archives and did not see 
anything about this problem, so I did a bit of experimenting on my own. 
One simple case that causes IDLE to hang is to simply close the shell 
while the program that it is executing is waiting for input. After IDLE 
asks if it should kill the program, it usually hangs. If it doesn't do 
this the first time, a couple of <f5>-close sequences will produce it.

I modified PyShell.py in IDLE 1.03 by adding a call to cancel_callback() 
before closing the shell window. This seems to solve the problem 
(perhaps in an inelegant way). I do not know yet if fixing this 
"special" case solves the larger instability problems. I'm hoping some 
of the reader of edu-sig are trying it out and will let me know.

In the mean time, I'd appreciate hearing if this is a known problem that 
is being worked on in IDLE. My preliminary test of IDLE 1.1 shows that 
it still suffers from the specific hang that I've identified.

--John
Michael Foord | 17 Dec 2004 13:25

Infinite Subprocesses and IDLE

A couple of weeks ago (? - approx !) I posted a question to this group. 
I was trying to build IDLE with py2exe and was getting an infinite 
number of subprocesses launched.

I didn't get a response - but in the process of experimenting with 
'testenv' (experimental 'Python runtime' that is becoming 'movable 
python') I discovered the problem. In the spawn_subprocess function in 
PyShell.py it uses sys.executable to launch the subprocess.

When I was freezing IDLE with py2exe - the program pointed to by 
sys.executable was idle.exe... which launched idle.exe... which launched 
idle.exe !

With testenv I hacked PyShell so that it launched a genuine subprocess 
and got it a lot closer to working. It didn't look like the two 
processes  were 'talking to each other' properly though.

In fact SPE with wxpython works without amendment - and I'm getting 
assistance from Stani on the 'movable python' project - so I probably 
*won't* continue to try and get IDLE working. I thought I would send 
this for the sake of completeness though.

Regards,

Fuzzyman
http://www.voidspace.org.uk/atlantibots/pythonutils.html
Kurt B. Kaiser | 18 Dec 2004 08:05
Picon
Favicon

Re: Leaving subprocesses hanging

John Zelle <john.zelle <at> wartburg.edu> writes:

> I'm new to the idle-dev list, but felt I needed to post here for some
> assistance. I am in communication with a number of college faculty
> using Python to teach introductory programming courses. There has been
> growing frustration that newer versions of IDLE seem to be less
> stable. In particular, especially under Windows XP, there are times
> when IDLE becomes unresponsive (hangs). This seems to be related to
> losing proper communication with its subprocess. The only way to get
> things cleaned up again is to go into the process manager and kill the
> stray pythonw processes. Unfortunately, the behavior is sporadic and
> hard to pin down.

This is the major difficulty with using subprocess execution on
Windows.

I spent quite a bit of time on the 'hanging subprocess' bug a year and
a half ago.  The bug was so persistent I've named it 'Freddy'.

My priority with IDLE is to choose stability over bells/whistles.
IDLE is intended to be used for introductory programming as well as by
advanced programmers, but beginners take precedence in my view.

At one time (May '03), I was interrupting the subprocess before
restarting it but the resulting traceback was slowing down the restart
considerably.  So I redesigned the subprocess so that a loss of socket
connection to the GUI would invoke an interrupt of the main thread
(which is executing the user's code).  The GUI causes the subprocess to
restart by simply closing the socket.  On Unix, a TERM signal is also
sent to the subprocess, but that's not available on Windows.

> I did a little poking around in the idle-dev archives and did not
>see anything about this problem, so I did a bit of experimenting on
>my own. One simple case that causes IDLE to hang is to simply close
>the shell while the program that it is executing is waiting for
>input. After IDLE asks if it should kill the program, it usually
>hangs. If it doesn't do this the first time, a couple of <f5>-close
>sequences will produce it.

OK, so I assume you are using something like

.>>> a = raw_input('prompt: ')

and then either clicking the shell window close widget or using F5.
That's actually two different scenarios.  I'll go off and duplicate
them.

> I modified PyShell.py in IDLE 1.03 by adding a call to
> cancel_callback() before closing the shell window. This seems to
> solve the problem (perhaps in an inelegant way). 

Where, exactly, did you put this code?  Did it fix the problem
you mentioned with <F5>-close sequences?

> I do not know yet if fixing this "special" case solves the larger
> instability problems. 

Shutting down the subprocess on Windows involves having it detect the
loss of connection and then successfully shut down the main thread,
the socket thread, and any threads associated with GUI communication.
It's complicated, and 'fixes' tend to regress older issues.

> I'm hoping some of the reader of edu-sig are trying it out and will
> let me know.
>
> In the mean time, I'd appreciate hearing if this is a known problem
> that is being worked on in IDLE. My preliminary test of IDLE 1.1 shows
> that it still suffers from the specific hang that I've identified.

It's an old problem which I thought was fixed since it hasn't been
reported recently.

I hope that edu-sig and c.l.p will bring stability issues to this list
if they can't enter them on the Python Bug tracker.

I'm also interested in discussing IDLE usability issues, especially
in an educational context.  That's appropriate for this list.

--

-- 
KBK
John Zelle | 18 Dec 2004 17:03

Re: Leaving subprocesses hanging

Kurt,

Thanks for the reply on this. Very helpful info.

Kurt B. Kaiser wrote:

>John Zelle <john.zelle <at> wartburg.edu> writes:
>
>  
>
>>I'm new to the idle-dev list, but felt I needed to post here for some
>>assistance. I am in communication with a number of college faculty
>>using Python to teach introductory programming courses. There has been
>>growing frustration that newer versions of IDLE seem to be less
>>stable. In particular, especially under Windows XP, there are times
>>when IDLE becomes unresponsive (hangs). This seems to be related to
>>losing proper communication with its subprocess. The only way to get
>>things cleaned up again is to go into the process manager and kill the
>>stray pythonw processes. Unfortunately, the behavior is sporadic and
>>hard to pin down.
>>    
>>
>
>This is the major difficulty with using subprocess execution on
>Windows.
>
>I spent quite a bit of time on the 'hanging subprocess' bug a year and
>a half ago.  The bug was so persistent I've named it 'Freddy'.
>
>My priority with IDLE is to choose stability over bells/whistles.
>IDLE is intended to be used for introductory programming as well as by
>advanced programmers, but beginners take precedence in my view.
>
>At one time (May '03), I was interrupting the subprocess before
>restarting it but the resulting traceback was slowing down the restart
>considerably.  So I redesigned the subprocess so that a loss of socket
>connection to the GUI would invoke an interrupt of the main thread
>(which is executing the user's code).  The GUI causes the subprocess to
>restart by simply closing the socket.  On Unix, a TERM signal is also
>sent to the subprocess, but that's not available on Windows.
>
>  
>
Stability would also be my first choice in IDLE. It's just so crucial 
for new programmers to have an evironment that responds the way that 
they expect it to. I'm glad to hear that someone has been working on 
'Freddy.'

>>I did a little poking around in the idle-dev archives and did not
>>see anything about this problem, so I did a bit of experimenting on
>>my own. One simple case that causes IDLE to hang is to simply close
>>the shell while the program that it is executing is waiting for
>>input. After IDLE asks if it should kill the program, it usually
>>hangs. If it doesn't do this the first time, a couple of <f5>-close
>>sequences will produce it.
>>    
>>
>
>OK, so I assume you are using something like
>
>.>>> a = raw_input('prompt: ')
>
>and then either clicking the shell window close widget or using F5.
>That's actually two different scenarios.  I'll go off and duplicate
>them.
>
>  
>
This is basically it. I actually put this line in a script, load the 
script and <F5> it. When the shell is waiting for input, closing the 
shell window either by clicking on the window's close box or by 
selecting close from the file menu will produce the error. From what I 
saw in the code, these are equivalent actions. I think as of version 
1.04, rather than a pure hang what happens is that the next time <F5> is 
done, IDLE pops up the message window about the socket being in use.

If the shell window is waiting for user input and you do <F5> in the 
script window, the shell does do a clean restart, although it seems as 
if one needs to hit <return> in the shell window before the prompt will 
display again.

>>I modified PyShell.py in IDLE 1.03 by adding a call to
>>cancel_callback() before closing the shell window. This seems to
>>solve the problem (perhaps in an inelegant way). 
>>    
>>
>
>Where, exactly, did you put this code?  Did it fix the problem
>you mentioned with <F5>-close sequences?
>
>  
>
I modified the PyShell close method:

    def close(self):
        "Extend EditorWindow.close()"
        if self.executing:
            response = tkMessageBox.askokcancel(
                "Kill?",
                "The program is still running!\n Do you want to kill it?",
                default="ok",
                parent=self.text)
            if response == False:
                return "cancel"
        self.cancel_callback() # This line inserted by JMZ
        self.closing = True
        # Wait for poll_subprocess() rescheduling to stop
        self.text.after(2 * self.pollinterval, self.close2)

This fix does solve the problem that I describe. I noticed that sending 
a keyboard interrupt before closing the shell seemed to take care of the 
problem, so I just inserted the cancel_callback() into the close 
sequence. It seemed the safest way to go (without understanding the 
intricacies of the subprocess code). It does have the drawback of 
producing a bit of "chatter" in the shell window just before it goes away.

By the way, this same bug appears under Linux as well, so It's not just 
the Windows subprocess issues in this case.

This seems to work fine on IDLE 1.03-1.04. I've been working with it for 
a couple days and have not noticed any problems. Unfortunately, last 
night I tried the same fix on IDLE 1.1, and I ran into some problems. 
Has the subprocess code undergone significant revision from 1.04 to 1.1?

>>I do not know yet if fixing this "special" case solves the larger
>>instability problems. 
>>    
>>
>
>Shutting down the subprocess on Windows involves having it detect the
>loss of connection and then successfully shut down the main thread,
>the socket thread, and any threads associated with GUI communication.
>It's complicated, and 'fixes' tend to regress older issues.
>
>  
>
Yes, this does seem to be a particularly ticklish issue. That's why I 
used a Band-Aid approach.  Anecdotally, the general instability problem 
seems to have gotten a bit worse from version 1.0 to 1.03. We run 1.0 in 
our labs and have had only occasional problems, most of which I think 
are linked to quitting the shell when the subprocess is expecting input. 
I've heard from other schools that their problems have been so severe 
and frustrating (versions 1.03 and 1.04) that they are looking at 
alternatives.

>>I'm hoping some of the reader of edu-sig are trying it out and will
>>let me know.
>>
>>In the mean time, I'd appreciate hearing if this is a known problem
>>that is being worked on in IDLE. My preliminary test of IDLE 1.1 shows
>>that it still suffers from the specific hang that I've identified.
>>    
>>
>
>It's an old problem which I thought was fixed since it hasn't been
>reported recently. 
>
>I hope that edu-sig and c.l.p will bring stability issues to this list
>if they can't enter them on the Python Bug tracker.
>
>  
>
OK, could you enlighten me a bit. Where should I have been looking to 
find what you've been working on, and where should we be reporting such 
issues. Obviously, I finally decided to post here because of the 
questions that I've been getting from colleagues at other schools. As I 
said, our problems have not been so serious. To be honest, I haven't 
even been able to track down who's even actively developing IDLE at this 
point. The python.org/idle page is not really that informative.

>I'm also interested in discussing IDLE usability issues, especially
>in an educational context.  That's appropriate for this list.
>
>  
>
Great, then perhaps I've found another "home."

Thanks for all the work you and others already done on IDLE. It's been a 
great IDE for us. It's nice to be able to point people to Python and say 
that everything you need, IDE and all, is in the bundle.

--John
Arthur | 19 Dec 2004 15:09
Favicon

re: Leaving subprocesses hanging


John writes -

>This seems to work fine on IDLE 1.03-1.04. I've been working with it for 
>a couple days and have not noticed any problems. Unfortunately, last 
>night I tried the same fix on IDLE 1.1, and I ran into some problems. 
>Has the subprocess code undergone significant revision from 1.04 to 1.1?

Is there a possibility that the issue is differences in the versions of
tcl/tk against which it is running, rather than in changes in Idle .

It is known that threading related code that worked against 8.3 breaks under
8.4 as tcl seems to have changed its own threading model. There is some
writing out there by Martin v. Löwis about this change in tcl's model and
the changes it necessitated in Python's tkinter code. Unfortunately I can't
seem to trace my steps back to it right now. 

Is it reasonable to suspect there is relationship here somewhere with
Freddy?

Not that knowing that gets us anywhere in particular, but it might contain a
clue.

Are you running IDLE 1.03 against the same tcl/tk versions as you are
running IDLE 1.1?

Art
Jon Schull | 19 Dec 2004 00:52

can't run idle. ImportError: cannot import name print_exc

Greetings.  I've lost the ability to run idle.

Perhaps the information below will help?

208-186-56-189:~ jis$ idle
-bash: /sw/lib/python2.3/idlelib/idle.py: Permission denied
208-186-56-189:~ jis$ sudo idle
Password:
Traceback (most recent call last):
   File "/sw/bin/idle", line 3, in ?
     from idlelib.PyShell import main
   File 
"/sw/src/root-python23-2.3.4-2/sw/lib/python2.3/idlelib/PyShell.py", 
line 11, in ?
   File "/sw/lib/python2.3/threading.py", line 13, in ?
     from traceback import print_exc as _print_exc
ImportError: cannot import name print_exc

208-186-56-189:~ jis$ find idle
find: idle: No such file or directory

208-186-56-189:~ jis$ /sw/bin/python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /sw/lib/python2.3/site.pyc matches /sw/lib/python2.3/site.py
import site # precompiled from /sw/lib/python2.3/site.pyc
# /sw/lib/python2.3/os.pyc matches /sw/lib/python2.3/os.py
import os # precompiled from /sw/lib/python2.3/os.pyc
import posix # builtin
# /sw/lib/python2.3/posixpath.pyc matches /sw/lib/python2.3/posixpath.py
import posixpath # precompiled from /sw/lib/python2.3/posixpath.pyc
# /sw/lib/python2.3/stat.pyc matches /sw/lib/python2.3/stat.py
import stat # precompiled from /sw/lib/python2.3/stat.pyc
# /sw/lib/python2.3/UserDict.pyc matches /sw/lib/python2.3/UserDict.py
import UserDict # precompiled from /sw/lib/python2.3/UserDict.pyc
# /sw/lib/python2.3/copy_reg.pyc matches /sw/lib/python2.3/copy_reg.py
import copy_reg # precompiled from /sw/lib/python2.3/copy_reg.pyc
# /sw/lib/python2.3/types.pyc matches /sw/lib/python2.3/types.py
import types # precompiled from /sw/lib/python2.3/types.pyc
# /sw/lib/python2.3/warnings.pyc matches /sw/lib/python2.3/warnings.py
import warnings # precompiled from /sw/lib/python2.3/warnings.pyc
# /sw/lib/python2.3/linecache.pyc matches /sw/lib/python2.3/linecache.py
import linecache # precompiled from /sw/lib/python2.3/linecache.pyc
import encodings # directory /sw/lib/python2.3/encodings
# /sw/lib/python2.3/encodings/__init__.pyc matches 
/sw/lib/python2.3/encodings/__init__.py
import encodings # precompiled from 
/sw/lib/python2.3/encodings/__init__.pyc
# /sw/lib/python2.3/codecs.pyc matches /sw/lib/python2.3/codecs.py
import codecs # precompiled from /sw/lib/python2.3/codecs.pyc
import _codecs # builtin
# /sw/lib/python2.3/encodings/aliases.pyc matches 
/sw/lib/python2.3/encodings/aliases.py
import encodings.aliases # precompiled from 
/sw/lib/python2.3/encodings/aliases.pyc
# /sw/lib/python2.3/encodings/ascii.pyc matches 
/sw/lib/python2.3/encodings/ascii.py
import encodings.ascii # precompiled from 
/sw/lib/python2.3/encodings/ascii.pyc
Python 2.3.4 (#1, Nov  7 2004, 14:21:14)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import readline # dynamically loaded from 
/sw/lib/python2.3/lib-dynload/readline.so
 >>>

^c

# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] site
# cleanup[1] encodings
# cleanup[1] _codecs
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] encodings.ascii
# cleanup[1] codecs
# cleanup[1] readline
# cleanup[1] types
# cleanup[1] signal
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] os.path
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 4 unfreed ints in 1 out of 2 blocks
# cleanup floats

208-186-56-189:~ jis$ idle
-bash: /sw/lib/python2.3/idlelib/idle.py: Permission denied
208-186-56-189:~ jis$ /sw/bin/python /sw/lib/python2.3/idlelib/idle.py
Traceback (most recent call last):
   File "<string>", line 1, in ?
   File "/sw/lib/python2.3/idlelib/run.py", line 7, in ?
     import threading
   File "/sw/lib/python2.3/threading.py", line 13, in ?
     from traceback import print_exc as _print_exc
ImportError: cannot import name print_exc

^CTraceback (most recent call last):
   File "/sw/lib/python2.3/idlelib/idle.py", line 21, in ?
     PyShell.main()
   File "/sw/lib/python2.3/idlelib/PyShell.py", line 1287, in main
     flist.pyshell = PyShell(flist)
   File "/sw/lib/python2.3/idlelib/PyShell.py", line 769, in __init__
     self.interp.start_subprocess()
   File "/sw/lib/python2.3/idlelib/PyShell.py", line 362, in 
start_subprocess
     self.rpcclt.accept()
   File "/sw/lib/python2.3/idlelib/rpc.py", line 526, in accept
     working_sock, address = self.listening_sock.accept()
   File "/sw/lib/python2.3/socket.py", line 167, in accept
     sock, addr = self._sock.accept()
KeyboardInterrupt

208-186-56-189:~ jis$ sudo /sw/bin/python 
/sw/lib/python2.3/idlelib/idle.py
Password:
Traceback (most recent call last):
   File "<string>", line 1, in ?
   File "/sw/lib/python2.3/idlelib/run.py", line 7, in ?
     import threading
   File "/sw/lib/python2.3/threading.py", line 13, in ?
     from traceback import print_exc as _print_exc
ImportError: cannot import name print_exc

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Jon Schull, Ph.D.
Associate Professor
Information Technology
Rochester Institute of Technology
102 Lomb Memorial Drive
Rochester, New York 14623
schull <at> digitalgoods.com 585-738-6696
_______________________________________________
IDLE-dev mailing list
IDLE-dev <at> python.org
http://mail.python.org/mailman/listinfo/idle-dev

Gmane