[Python-Dev] Showstopper in import?
M.-A. Lemburg
mal@lemburg.com
Fri, 02 Feb 2001 10:01:34 +0100
Tim Peters wrote:
>
> Turns out IDLE no longer runs. Starting at line 88 of
> Tools/idle/EditorWindow.py we have this class defn:
>
> class EditorWindow:
>
> from Percolator import Percolator
> from ColorDelegator import ColorDelegator
> from UndoDelegator import UndoDelegator
> from IOBinding import IOBinding
> import Bindings
> from Tkinter import Toplevel
> from MultiStatusBar import MultiStatusBar
>
> about_title = about_title
> ...
>
> This leads to what looks like a bug (if we're to believe the error msg,
> which doesn't mean what it says):
>
> C:\Pyk>python tools/idle/idle.pyw
> Traceback (most recent call last):
> File "tools/idle/idle.pyw", line 2, in ?
> import idle
> File "C:\PYK\Tools\idle\idle.py", line 11, in ?
> import PyShell
> File "C:\PYK\Tools\idle\PyShell.py", line 15, in ?
> from EditorWindow import EditorWindow, fixwordbreaks
> File "C:\PYK\Tools\idle\EditorWindow.py", line 88, in ?
> class EditorWindow:
> File "C:\PYK\Tools\idle\EditorWindow.py", line 90, in EditorWindow
> from Percolator import Percolator
> SyntaxError: 'from ... import *' may only occur in a module scope
> Hit return to exit...
I have already reported this to Jeremy. There are other instances
of 'from x import *' in function and class scope too, e.g.
some test() functions in the standard dist do this.
I am repeating myself here, but I think that this single change
will cause so many people to find their scripts are failing
that it is really not worth it.
Better issue a warning than raise an exception here !
--
Marc-Andre Lemburg
______________________________________________________________________
Company: http://www.egenix.com/
Consulting: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/