Skip to content

Commit

Permalink
Merge pull request #38 from Digenis/master
Browse files Browse the repository at this point in the history
[MRG+1] exception handling was hiding original exception
  • Loading branch information
kmike committed Apr 25, 2016
2 parents 04e6e14 + 2ca8d8a commit 5006628
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
XPath selectors based on lxml
"""

import sys

import six
from lxml import etree

Expand Down Expand Up @@ -175,9 +177,10 @@ def xpath(self, query):
try:
result = xpathev(query, namespaces=self.namespaces,
smart_strings=self._lxml_smart_strings)
except etree.XPathError:
msg = u"Invalid XPath: %s" % query
raise ValueError(msg if six.PY3 else msg.encode("unicode_escape"))
except etree.XPathError as exc:
msg = u"XPath error: %s in %s" % (exc, query)
msg = msg if six.PY3 else msg.encode('unicode_escape')
six.reraise(ValueError, ValueError(msg), sys.exc_info()[2])

if type(result) is not list:
result = [result]
Expand Down

0 comments on commit 5006628

Please sign in to comment.