Kaydet (Commit) 71707f3b authored tarafından Jack Jansen's avatar Jack Jansen

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.
üst 51e2651b
...@@ -36,7 +36,9 @@ def print_exc(limit=None, file=None): ...@@ -36,7 +36,9 @@ def print_exc(limit=None, file=None):
class PyInteractive: class PyInteractive:
def __init__(self): def __init__(self):
import codeop
self._pybuf = "" self._pybuf = ""
self._compile = codeop.Compile()
def executeline(self, stuff, out = None, env = None): def executeline(self, stuff, out = None, env = None):
if env is None: if env is None:
...@@ -72,7 +74,7 @@ class PyInteractive: ...@@ -72,7 +74,7 @@ class PyInteractive:
return return
try: try:
code = compile(self._pybuf, "<input>", "single") code = self._compile(self._pybuf, "<input>", "single")
except SyntaxError, err: except SyntaxError, err:
pass pass
except: except:
...@@ -84,12 +86,12 @@ class PyInteractive: ...@@ -84,12 +86,12 @@ class PyInteractive:
return return
try: try:
code1 = compile(self._pybuf + "\n", "<input>", "single") code1 = self._compile(self._pybuf + "\n", "<input>", "single")
except SyntaxError, err1: except SyntaxError, err1:
pass pass
try: try:
code2 = compile(self._pybuf + "\n\n", "<input>", "single") code2 = self._compile(self._pybuf + "\n\n", "<input>", "single")
except SyntaxError, err2: except SyntaxError, err2:
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment