[Idle-dev] RE: [Tutor] New problem with -Qnew and IDLE?

Tim Peters tim.one@home.com
Wed, 23 Jan 2002 00:15:09 -0500


[Gregor Lingl]
> Has anybody an explanation vor this:

Better, I checked in a fix <wink>, so it should work in 2.2.1 (when it's
released).

> I started IDLE with the -Qnew switch.
> (I have a copy of the IDLE-Icon with this switch on my desktop)
> Then I did the following in IDLE's Python-Shell-Window:
>
> >>> def ggt(a,b):
>       while b:  ##### WHEN NOW I HIT ENTER,
>                 ##### THE RESULT WAS:
>
> >>> Exception in Tkinter callback
> ...
>  File "C:\Python22\Tools\idle\AutoIndent.py", line 442, in _make_blanks
>    return '\t' * ntabs + ' ' * nspaces
> TypeError: unsupported operand type(s) for *: 'str' and 'float'
> def ggt(a,b):
>     while b:

IDLE is trying to figure out how to auto-indent the next line.  At one point
it does

            effective = (effective / tabwidth + 1) * tabwidth

That doesn't work as intended under -Qnew, so I changed it to

            effective = (int(effective / tabwidth) + 1) * tabwidth

(you can change that line similarly in your copy of AutoIndent.py, of
course).

> ...
> I feel more and more, that there is some strange instability in IDLE
> connected with the -Qnew switch .

Not really strange.  We had 2.2 alpha and beta releases for half a year, and
AFAICT nobody even *tried* -Qnew until after 2.2 final was released (did
you?).  The only thing I personally tried under the combo of IDLE and -Qnew
was a one-liner to make sure 3/2 returned 1.5; I'm afraid that's all I had
time for.

> P.S.: I'm interested in these problems, because in my opinion it is
> an important, if not crucial point to have a not only simple but also
> stable and reliable programming environment, when working with
> highschool students, who are just beginning to learn to program.

You should read the PEP for its warnings about using -Qnew.  At this stage
it's for pioneers; if you can't tolerate some early glitches, I advise that
you simply leave it alone.  Else you can be very helpful by using it and
reporting what goes wrong.  That you're the first person to report this bug
means you're the first person to try typing a "def" into an IDLE shell
under -Qnew!  We need *somebody* brave enough to try that <wink>.