Skip to content

Commit

Permalink
exception handling was hiding original exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Digenis committed Apr 22, 2016
1 parent 04e6e14 commit bd72121
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py33, py34
envlist = py27, py33, py34, py35

[testenv]
deps =
Expand Down

0 comments on commit bd72121

Please sign in to comment.