]> granicus.if.org Git - python/commitdiff
Patch by Mark Day to allow from __future__ imports. Looks harmless
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 7 Sep 2001 10:11:31 +0000 (10:11 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 7 Sep 2001 10:11:31 +0000 (10:11 +0000)
enough, but may have side-effects because it preallocates a single
codeop.Compiler() to compile all statements the user enters.

Just: please review and retract/modify if necessary.

Mac/Tools/IDE/PyInteractive.py

index dc75e4b3e97b40a48870bb752d8c043b78d21e44..3ad02c595b3652a9564772b170f060e37ef627bd 100644 (file)
@@ -36,7 +36,9 @@ def print_exc(limit=None, file=None):
 class PyInteractive:
        
        def __init__(self):
+               import codeop
                self._pybuf = ""
+               self._compile = codeop.Compile()
        
        def executeline(self, stuff, out = None, env = None):
                if env is None:
@@ -72,7 +74,7 @@ class PyInteractive:
                                return
                        
                        try:
-                               code = compile(self._pybuf, "<input>", "single")
+                               code = self._compile(self._pybuf, "<input>", "single")
                        except SyntaxError, err:
                                pass
                        except:
@@ -84,12 +86,12 @@ class PyInteractive:
                                return
                        
                        try:
-                               code1 = compile(self._pybuf + "\n", "<input>", "single")
+                               code1 = self._compile(self._pybuf + "\n", "<input>", "single")
                        except SyntaxError, err1:
                                pass
                        
                        try:
-                               code2 = compile(self._pybuf + "\n\n", "<input>", "single")
+                               code2 = self._compile(self._pybuf + "\n\n", "<input>", "single")
                        except SyntaxError, err2:
                                pass