Skip to content

Commit

Permalink
Some errors don't have line or column, return None
Browse files Browse the repository at this point in the history
re.search() can return None, if it does don't try to return not existant
restults
  • Loading branch information
coledarr committed Oct 16, 2012
1 parent e0423e9 commit e008479
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xpath/xpath.py 100644 → 100755
Expand Up @@ -439,8 +439,11 @@ def set_error_position(self, error):


def first_group_match(self, pattern, text): def first_group_match(self, pattern, text):
search = re.search(pattern, text) search = re.search(pattern, text)
groups = search.groups() if search is not None:
return groups[0] groups = search.groups()
return groups[0]
else:
return None


class XPathSearchErrorResult(XPathErrorResult): class XPathSearchErrorResult(XPathErrorResult):
def __init__(self, error, xpath): def __init__(self, error, xpath):
Expand Down

0 comments on commit e008479

Please sign in to comment.