[Python-bugs-list] [Bug #115690] Dr. Watson error on Python2.0b2 Idle 0.6 WinNT4.0 SP6

noreply@sourceforge.net noreply@sourceforge.net
Fri, 6 Oct 2000 16:09:15 -0700


Bug #115690, was updated on 2000-Sep-29 14:55
Here is a current snapshot of the bug.

Project: Python
Category: Tkinter
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 6
Summary: Dr. Watson error on Python2.0b2 Idle 0.6 WinNT4.0 SP6

Details: I get a Dr. Watson error:

    pythonw.exe
    Exception: access violation (0xc0000005), 
    Address: 0x00e31652

when I run the following code in Idle 0.6, using Edit->Run Script:

---%<---cut---%<---

import unicodedata
for c in range(0x10000):
    x=unichr(c)
    try:
        b = unicodedata.numeric(x)
        #print "numeric:", repr(x)
        try:
            a = unicodedata.digit(x)
            if a != b:
                print "bad" , repr(x)
        except:
            print "Numeric but not digit", hex(c), x.encode("utf8"), \
                  "numeric ->", b
    except:
        pass

---%<---cut---%<---

(This code was recently posted on python-dev)

I've modified my .idle file, adding 

    [EditorWindow]
    font-name=tahoma


Follow-Ups:

Date: 2000-Sep-29 21:42
By: jhylton

Comment:
Marc-Andre can you check whether this is a Unicode bug that is going to come up with or without idle.  If it seems Idle specific, please assign it to Guido or Tim.  If not, it's yours :-).


-------------------------------------------------------

Date: 2000-Oct-03 10:23
By: lemburg

Comment:
I can't reproduce this on Linux, so it seems that it is related to the way TCL/Tk
displays UTF-8 data. Another possibility would be an optimization error
which doesn't happen with gcc.

Tim, could you try this on Windows and possibly tell me where the segfault
occurs in the code ?

-------------------------------------------------------

Date: 2000-Oct-03 11:27
By: gvanrossum

Comment:
Can't reproduce it on Win98SE either. (And I did try setting font-name to tahoma.)
-------------------------------------------------------

Date: 2000-Oct-04 20:42
By: tim_one

Comment:
Assigned back to Guido, because it appears identical to bug 113803, which Guido assigned to himself.

Guido, I can reproduce the problem, and regardless of font (e.g., let it use the default) on Win98SE by letting the program run to completion, and then hitting the ENTER key *twice* (first time gets an IDLE prompt, second time blows up).  It's in exactly the same place then as 113803, trying to decref a NULL pointer in _tkinter.c's AsString.

Note that there *may* be another bug here specific to NT and/or W2K too, in that W9x have much feebler Unicode support.

-------------------------------------------------------

Date: 2000-Oct-06 10:13
By: gvanrossum

Comment:
Fixed the Tkinter bug, so closing this. Please check that this is indeed fixed in the CVS version (or wait for release candidate 1, Monday).
-------------------------------------------------------

Date: 2000-Oct-06 10:42
By: tim_one

Comment:
The crash went away for me (Win98SE, default font), but upon hitting the 2nd RETURN I get a new problem:

>>> Exception in Tkinter callback
Traceback (most recent call last):
  File "c:\code\python\dist\src\lib\lib-tk\Tkinter.py", line 1287, in __call__
    return apply(self.func, args)
  File "../tools/idle\PyShell.py", line 573, in enter_callback
    self.auto.auto_indent(event)
  File "C:\Code\python\dist\src\tools\idle\AutoIndent.py", line 269, in newline_and_indent_event
    c = y.get_continuation_type()
  File "C:\Code\python\dist\src\tools\idle\PyParse.py", line 332, in get_continuation_type
    self._study1()
  File "C:\Code\python\dist\src\tools\idle\PyParse.py", line 220, in _study1
    str = string.translate(str, _tran)
  File "c:\code\python\dist\src\lib\string.py", line 308, in translate
    return s.translate(table, deletions)
TypeError: translate requires exactly 1 argument; 2 given

I'll look into it.
-------------------------------------------------------

Date: 2000-Oct-06 11:10
By: tim_one

Comment:
Reopened this bug, cuz I need another set of eyes!  Guido, does the latest symptom occur for you too (run the program, hit ENTER twice, get a traceback from string.translate)?  The complaint doesn't make sense (the code for string.translate does *not* require exactly 1 arg, and I can't trigger this msg unless I run the test program first).
-------------------------------------------------------

Date: 2000-Oct-06 11:38
By: tim_one

Comment:
*Something* is really hosed here.  We haven't even entered stringobject.c's string_translate by the time the traceback is generated (I know that because I set a breakpoint there and it wasn't hit).
-------------------------------------------------------

Date: 2000-Oct-06 11:57
By: gvanrossum

Comment:
Betcha it's a Unicode object! There, translate() only takes 1 arg.
-------------------------------------------------------

Date: 2000-Oct-06 12:33
By: gvanrossum

Comment:
I think I understand what's going on, but I don't want to fix it. It's actually in a piece of IDLE that Tim hacked long ago! The VC++ debugger is quite useless in figuring this out, but if you use the IDLE stack viewer you can track exactly what happens.

- string.translate() gets called with a Unicode string arg -- this causes the crash.

- This is because self.str is u'\012'. That seems to have been extracted from the text buffer. I'm not quite sure how, but

- a few calls further up the stack, AutoIndent.newline_and_indent() seems to have extracted the last non-blank line from the PyShell outbut buffer, which happens to contain a Unicode character.

- I can reproduce this quite easily by something like 
   >>> print u"\u1234".encode("utf8")
and then hit return twice.

Back to Tim!


-------------------------------------------------------

Date: 2000-Oct-06 16:09
By: tim_one

Comment:
Thanks for the clues, Guido!  Fixed and Closed.

The Unicode newline is coming straight from text.get().  PyParse doesn't care about Unicode characters, but wasn't expecting any either.  Added code to change non-7-bit Unicode chars into "x" before parsing, so the parse functions can continue to work with 8-bit strings.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=115690&group_id=5470