- if self._command_list is not None and not callable(retval):
- raise CommandListError("%s not allowed in command list" % command)
- self._write_command(command, args)
- if self._command_list is None:
+ if self._command_list is not None:
+ if not callable(retval):
+ raise CommandListError("%s not allowed in command list" %
+ command)
+ self._write_command(command, args)
+ self._command_list.append(retval)
+ else:
+ self._write_command(command, args)