Commit 19a5b07c authored by Boxiang Sun's avatar Boxiang Sun

Enable part of this code because Pyston support co_names now.

We have to support self.used. This part of code was disabled
because Pyston didn't support co_names. Now enable it. But Pyston's
bytecode is different than CPython bytecode. So we can't use the code
which rely on co_code part.
parent ffbdc730
...@@ -72,11 +72,11 @@ class RestrictionCapableEval: ...@@ -72,11 +72,11 @@ class RestrictionCapableEval:
if self.ucode is None: if self.ucode is None:
# Use the standard compiler. # Use the standard compiler.
co = compile(self.expr, '<string>', 'eval') co = compile(self.expr, '<string>', 'eval')
# Pyston change: return code directly if self.used is None:
# if self.used is None: # Examine the code object, discovering which names
# # Examine the code object, discovering which names # the expression needs.
# # the expression needs. names=list(co.co_names)
# names=list(co.co_names) # Pyston change: Pyston use different bytecode system than CPython
# used={} # used={}
# i=0 # i=0
# code=co.co_code # code=co.co_code
...@@ -92,6 +92,7 @@ class RestrictionCapableEval: ...@@ -92,6 +92,7 @@ class RestrictionCapableEval:
# elif c >= HAVE_ARGUMENT: i=i+3 # elif c >= HAVE_ARGUMENT: i=i+3
# else: i=i+1 # else: i=i+1
# self.used=tuple(used.keys()) # self.used=tuple(used.keys())
self.used=tuple(names)
self.ucode=co self.ucode=co
def eval(self, mapping): def eval(self, mapping):
......
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