commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 20/25: grc: faulty callback code if setter


From: git
Subject: [Commit-gnuradio] [gnuradio] 20/25: grc: faulty callback code if setter call contained a variable block id
Date: Fri, 27 May 2016 19:14:59 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 1319af2b6cd4631a28a969a4cb54f2f25b8ab8d5
Author: Sebastian Koslowski <address@hidden>
Date:   Tue May 17 13:24:54 2016 +0200

    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".
---
 grc/core/generator/Generator.py | 5 +++--
 grc/core/utils/expr_utils.py    | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py
index ba272ab..fb7a3af 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 240b99e..2059cef 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]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]