1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

codeparser.py: Fix storing of hash values as object references can be corrupted

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
Richard Purdie
2010-09-26 15:33:19 +08:00
parent cf09c7a1e3
commit d85dc37b73
+11 -8
View File
@@ -4,7 +4,7 @@ from bb import msg, utils
import ast import ast
import codegen import codegen
PARSERCACHE_VERSION = 1 PARSERCACHE_VERSION = 2
try: try:
import cPickle as pickle import cPickle as pickle
@@ -177,11 +177,11 @@ class PythonParser():
def parse_python(self, node): def parse_python(self, node):
h = hash(node) h = hash(str(node))
if h in pythonparsecache: if h in pythonparsecache:
self.references = pythonparsecache[h].references self.references = pythonparsecache[h]["refs"]
self.execs = pythonparsecache[h].execs self.execs = pythonparsecache[h]["execs"]
return return
code = compile(check_indent(str(node)), "<string>", "exec", code = compile(check_indent(str(node)), "<string>", "exec",
@@ -196,7 +196,9 @@ class PythonParser():
self.references.update(visitor.var_execs) self.references.update(visitor.var_execs)
self.execs = visitor.direct_func_calls self.execs = visitor.direct_func_calls
pythonparsecache[h] = self pythonparsecache[h] = {}
pythonparsecache[h]["refs"] = self.references
pythonparsecache[h]["execs"] = self.execs
class ShellParser(): class ShellParser():
def __init__(self): def __init__(self):
@@ -209,10 +211,10 @@ class ShellParser():
commands it executes. commands it executes.
""" """
h = hash(value) h = hash(str(value))
if h in shellparsecache: if h in shellparsecache:
self.execs = shellparsecache[h].execs self.execs = shellparsecache[h]["execs"]
return self.execs return self.execs
try: try:
@@ -224,7 +226,8 @@ class ShellParser():
self.process_tokens(token) self.process_tokens(token)
self.execs = set(cmd for cmd in self.allexecs if cmd not in self.funcdefs) self.execs = set(cmd for cmd in self.allexecs if cmd not in self.funcdefs)
shellparsecache[h] = self shellparsecache[h] = {}
shellparsecache[h]["execs"] = self.execs
return self.execs return self.execs