Skip to content

Commit ea664ac

Browse files
authored
Resolve macro arguments within caller's scope (#373)
Fixes #366.
1 parent 17ecece commit ea664ac

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/xacro/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ def handle_macro_call(node, macros, symbols):
791791

792792
name = node.tagName[6:] # drop 'xacro:' prefix
793793
try:
794-
macros, symbols, m = resolve_macro(name, macros, symbols)
794+
scoped_macros, scoped_symbols, m = resolve_macro(name, macros, symbols)
795795
body = m.body.cloneNode(deep=True)
796796

797797
except KeyError:
@@ -800,8 +800,8 @@ def handle_macro_call(node, macros, symbols):
800800
macrostack.append(m)
801801

802802
# Expand the macro
803-
scoped_symbols = Table(symbols) # new local name space for macro evaluation
804-
scoped_macros = Table(macros)
803+
scoped_symbols = Table(scoped_symbols) # new local name space for macro evaluation
804+
scoped_macros = Table(scoped_macros)
805805
params = m.params[:] # deep copy macro's params list
806806
for name, value in node.attributes.items():
807807
if name not in params:

test/test_xacro.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,12 +1370,10 @@ def test_property_resolution_with_namespaced_include(self):
13701370
<xacro:property name="var" value="main"/>
13711371
<xacro:B.bar arg="${ext}"/>
13721372
<xacro:B.bar arg="${var}"/>
1373-
<xacro:B.bar arg="${inner}"/>
13741373
</a>'''
13751374
res = '''<a version="1.0">
13761375
<a arg="main" ext="main" var="2"/>
1377-
<a arg="2" ext="main" var="2"/>
1378-
<a arg="int" ext="main" var="2"/>
1376+
<a arg="main" ext="main" var="2"/>
13791377
</a>'''
13801378
self.assert_matches(self.quick_xacro(src), res)
13811379

0 commit comments

Comments
 (0)