Skip to content

Commit 75569a3

Browse files
committed
Bugfix: Separate try on each call to node.view()
1 parent 056b8ba commit 75569a3

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

splipy/SplineModel.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,24 @@ def lookup(self, obj, add=False):
453453
# identity view on it.
454454
try:
455455
for candidate_node in self.internal[lower_nodes[-1]]:
456-
return candidate_node.view(obj)
457-
# FIXME: It might be useful to optionally not silence OrientationError,
458-
# since that more often than not indicates a real error
459-
except (KeyError, OrientationError):
460-
if not add:
461-
raise KeyError("No such object found")
462-
node = TopologicalNode(self, obj, lower_nodes)
463-
# Assign the new node to each possible permutation of lower-order
464-
# nodes. This is slight overkill since some of these permutations
465-
# are invalid, but c'est la vie.
466-
for p in permutations(lower_nodes[-1]):
467-
self.internal.setdefault(p, []).append(node)
468-
return node.view()
456+
try:
457+
return candidate_node.view(obj)
458+
# FIXME: It might be useful to optionally not silence OrientationError,
459+
# since that more often than not indicates a real error
460+
except OrientationError:
461+
pass
462+
except KeyError:
463+
pass
464+
465+
if not add:
466+
raise KeyError("No such object found")
467+
node = TopologicalNode(self, obj, lower_nodes)
468+
# Assign the new node to each possible permutation of lower-order
469+
# nodes. This is slight overkill since some of these permutations
470+
# are invalid, but c'est la vie.
471+
for p in permutations(lower_nodes[-1]):
472+
self.internal.setdefault(p, []).append(node)
473+
return node.view()
469474

470475
def add(self, obj):
471476
"""Add new nodes to the graph to accommodate the given object, then return the

0 commit comments

Comments
 (0)