Skip to content

Commit f1fb21b

Browse files
committed
Check attribute name before doing hasattr().
This addresses #207 by first checking that the attribute that is being accessed is not named the same as the attribute that is being used to lookup other methods.
1 parent 71f0488 commit f1fb21b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/prpy/base/robot.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ def __getattr__(self, name):
9898
# __methods__ bypass __getattribute__.
9999
self = bind.InstanceDeduplicator.get_canonical(self)
100100

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

104106
delegate_method = getattr(self.planner, name)
@@ -107,15 +109,19 @@ def wrapper_method(*args, **kw_args):
107109
return self._PlanWrapper(delegate_method, args, kw_args)
108110

109111
return wrapper_method
110-
elif (hasattr(self, 'actions') and self.actions is not None
112+
elif (name != 'actions'
113+
and hasattr(self, 'actions')
114+
and self.actions is not None
111115
and self.actions.has_action(name)):
112116

113117
delegate_method = self.actions.get_action(name)
114118
@functools.wraps(delegate_method)
115119
def wrapper_method(*args, **kw_args):
116120
return delegate_method(self, *args, **kw_args)
117121
return wrapper_method
118-
elif (hasattr(self, 'detector') and self.detector is not None
122+
elif (name != 'detector'
123+
and hasattr(self, 'detector')
124+
and self.detector is not None
119125
and self.detector.has_perception_method(name)):
120126

121127
delegate_method = getattr(self.detector, name)

0 commit comments

Comments
 (0)