Skip to content

Commit 24f4b5f

Browse files
committed
Merge pull request #208 from personalrobotics/bugfix/infinite_recursion
Check attribute name before doing hasattr().
2 parents 71f0488 + 9a4bcde commit 24f4b5f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/prpy/base/robot.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Robot(openravepy.Robot):
4545
def __init__(self, robot_name=None):
4646
self.actions = None
4747
self.planner = None
48+
self.detector = None
4849
self.robot_name = robot_name
4950

5051
try:
@@ -98,7 +99,9 @@ def __getattr__(self, name):
9899
# __methods__ bypass __getattribute__.
99100
self = bind.InstanceDeduplicator.get_canonical(self)
100101

101-
if (hasattr(self, 'planner') and self.planner is not None
102+
if (name != 'planner'
103+
and hasattr(self, 'planner')
104+
and self.planner is not None
102105
and self.planner.has_planning_method(name)):
103106

104107
delegate_method = getattr(self.planner, name)
@@ -107,15 +110,19 @@ def wrapper_method(*args, **kw_args):
107110
return self._PlanWrapper(delegate_method, args, kw_args)
108111

109112
return wrapper_method
110-
elif (hasattr(self, 'actions') and self.actions is not None
113+
elif (name != 'actions'
114+
and hasattr(self, 'actions')
115+
and self.actions is not None
111116
and self.actions.has_action(name)):
112117

113118
delegate_method = self.actions.get_action(name)
114119
@functools.wraps(delegate_method)
115120
def wrapper_method(*args, **kw_args):
116121
return delegate_method(self, *args, **kw_args)
117122
return wrapper_method
118-
elif (hasattr(self, 'detector') and self.detector is not None
123+
elif (name != 'detector'
124+
and hasattr(self, 'detector')
125+
and self.detector is not None
119126
and self.detector.has_perception_method(name)):
120127

121128
delegate_method = getattr(self.detector, name)

0 commit comments

Comments
 (0)