From 76eb3e53e73994dfc56c4f56020b57df30e79451 Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 10 Aug 2012 23:29:26 +0200 Subject: [PATCH] fixed recursion problem with properties. However, this does not fix the problem, that things that are used like properties (closures with different inputs) still are not properly executed, due to recursion detection. --- evaluate.py | 2 +- helpers.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/evaluate.py b/evaluate.py index dd9352c6..904d02aa 100644 --- a/evaluate.py +++ b/evaluate.py @@ -137,7 +137,7 @@ class Instance(Executable): def __init__(self, base, var_args=parsing.Array(None, None)): super(Instance, self).__init__(base, var_args) if str(base.name) in ['list', 'set'] \ - and builtin.Builtin.name == base.get_parent_until().path: + and builtin.Builtin.scope == base.get_parent_until(): # compare the module path with the builtin name. self.var_args = dynamic.check_array_instances(self) else: diff --git a/helpers.py b/helpers.py index 29f06648..ef4ca4fe 100644 --- a/helpers.py +++ b/helpers.py @@ -1,6 +1,9 @@ +import copy + import parsing import debug -import copy +import builtin + class RecursionDecorator(object): """ A decorator to detect recursions in statements """ @@ -10,11 +13,14 @@ class RecursionDecorator(object): self.current = None def __call__(self, stmt, *args, **kwargs): - # don't check param instances, they are not causing recursions - if isinstance(stmt, parsing.Param): + r = RecursionNode(stmt, self.current) + + # Don't check param instances, they are not causing recursions + # The same's true for the builtins, because the builtins are really + # simple. + if isinstance(stmt, parsing.Param) or r.script == builtin.Builtin.scope: return self.func(stmt, *args, **kwargs) - r = RecursionNode(stmt, self.current) if self.check_recursion(r): debug.warning('catched recursion', stmt, args, kwargs) return []