Skip to content

Commit 2ce1086

Browse files
author
Dilawar Singh
committed
Fixed: moose.le can caused segfault when used on moose.vec
This also fixes script mgblock.py BhallaLab/moose-examples#71
1 parent cb8b8c1 commit 2ce1086

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

python/moose/moose.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ def le(el=None):
133133
if not _moose.exists(el):
134134
raise ValueError('no such element')
135135
el = _moose.element(el)
136-
#elif isinstance(el, _moose.vec):
137-
# el = el[0]
136+
elif isinstance(el, _moose.vec):
137+
el = el[0]
138138
print("Elements under '%s'" % el)
139139
for ch in el.children:
140140
print(" %s" % ch.path)
141141
return [child.path for child in el.children]
142+
print(str([]))
143+
return []
142144

143145

144146
def syncDataHandler(target):

tests/core/test_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def test_other():
4949
def test_vec():
5050
a = moose.Pool('/p111', 100)
5151
v = moose.vec(a)
52+
53+
# le can cause segfault in some cases.
54+
moose.le(v)
55+
5256
assert len(v) == 100, len(v)
5357
assert v == v.vec
5458
assert v[0] == v.vec[0], (v[0], v.vec[0])

0 commit comments

Comments
 (0)