diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-09-07 10:11:31 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-09-07 10:11:31 (GMT) |
commit | 71707f3bb8be3a62518b43495881a5377ee82d0e (patch) | |
tree | 9465c86ac57bede9023aab122d60309a3b7dbad3 /Mac | |
parent | 51e2651b298cf59653133baf556f4cca3c569583 (diff) | |
download | cpython-71707f3bb8be3a62518b43495881a5377ee82d0e.zip cpython-71707f3bb8be3a62518b43495881a5377ee82d0e.tar.gz cpython-71707f3bb8be3a62518b43495881a5377ee82d0e.tar.bz2 |
Patch by Mark Day to allow from __future__ imports. Looks harmless
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.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Tools/IDE/PyInteractive.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Mac/Tools/IDE/PyInteractive.py b/Mac/Tools/IDE/PyInteractive.py index dc75e4b..3ad02c5 100644 --- a/Mac/Tools/IDE/PyInteractive.py +++ b/Mac/Tools/IDE/PyInteractive.py @@ -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 |