You could just replace this whole block with module = self._find_corresponding_module_for_location(problem_location) .  Don't catch the exceptions, as we would want them to be raised (and the hotfix changes how _find_corresponding_module_for_location works)