Consider this case:  

self.current_task_number == 10
len(self.task_states) == 10
len(self.task_xml) == 11

This code will leave self.current_task_number as 10, and now self.current_task_number is not a valid index into self.task_states.  I guess you want >= instead of > in the if statement.