summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-05-17 13:24:54 +0200
committerSebastian Koslowski <koslowski@kit.edu>2016-05-25 16:27:24 +0200
commit1319af2b6cd4631a28a969a4cb54f2f25b8ab8d5 (patch)
treed80f2c9d799df3677bbbccc1c07c491de93baaab
parent6647de1109cd0dffbb8668797a5bd98f54ffa053 (diff)
grc: faulty callback code if setter call contained a variable block id
(do-over of c85984f105106ff0a7e3b387d680e0f2f5884d55) If a block contains a callback of the form self.block_id.param = $param the generators subst routine produced self.block_id.self.param = self.param due to a faulty splitting of the expression in expr_utils.py. This should fix this problem by not tokenizing "VAR0.VAR1".
-rw-r--r--grc/core/generator/Generator.py5
-rw-r--r--grc/core/utils/expr_utils.py2
2 files changed, 4 insertions, 3 deletions
diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py
index ba272aba3f..fb7a3afb99 100644
--- a/grc/core/generator/Generator.py
+++ b/grc/core/generator/Generator.py
@@ -145,7 +145,7 @@ class TopBlockGenerator(object):
filter(lambda b: b.get_enabled() and not b.get_bypassed(), fg.blocks),
lambda b: b.get_id(), _get_block_sort_text
)
- deprecated_block_keys = set(block.get_name() for block in blocks if block.is_deprecated)
+ deprecated_block_keys = set(block.get_name() for block in blocks_all if block.is_deprecated)
for key in deprecated_block_keys:
Messages.send_warning("The block {!r} is deprecated.".format(key))
@@ -224,7 +224,8 @@ class TopBlockGenerator(object):
# Map var id to callbacks
def uses_var_id():
- return expr_utils.get_variable_dependencies(callback, [var_id])
+ used = expr_utils.get_variable_dependencies(callback, [var_id])
+ return used and 'self.' + var_id in callback # callback might contain var_id itself
callbacks = {}
for var_id in var_ids:
diff --git a/grc/core/utils/expr_utils.py b/grc/core/utils/expr_utils.py
index 240b99e7a1..2059ceff9f 100644
--- a/grc/core/utils/expr_utils.py
+++ b/grc/core/utils/expr_utils.py
@@ -99,7 +99,7 @@ def expr_replace(expr, replace_dict):
Returns:
a new expression with the prepend
"""
- expr_splits = expr_split(expr)
+ expr_splits = expr_split(expr, var_chars=VAR_CHARS + '.')
for i, es in enumerate(expr_splits):
if es in replace_dict.keys():
expr_splits[i] = replace_dict[es]